Thi...">All geek questions in one placeHow to prevent a child from inheriting CSS stylesI have a <div> element with a <p> element inside: <div style="font-size:10pt; color:red;"> This is my Parent Div. <p>This is my Child Paragraph.</p> My parent Div Ends Here. </div> How can I prevent my paragraph from inheriting CSS properties set in a <div> ?+4html cssVeena sujith Mar 13 '13 at 3:18source share3 answersIn your case, the best way is simply over the styles that the <p> element inherits:So, in your CSS file, which you should use instead of inline styles: .parent-div { font-size: 10pt; color: red; } .child-paragraph { font-size: 12pt; color: black; } +1Web_Designer Mar 13 '13 at 3:22source shareIn your child, node - <p style="font-size:12pt; color:black;">This is my child</p> Just set the inline style to whatever you want.0Shukla sannidhya Mar 13 '13 at 3:20source shareYou can use the > selector in CSS to select the immediate child p of the div .Script Link div > p { font-size:1.2 em; color: green; } 0hjpotter92 Mar 13 '13 at 3:24source shareSource: https://habr.com/ru/post/1468878/More articles:Multiple Stub Requests with webmock / rspec - ruby | fooobar.comhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1468874/split-string-with-commas-to-new-line&usg=ALkJrhgkOoBrarHbSxy8ZvG0tvxHaRJTtASQL merge function without specifying column names - mergeCan't resolve options? - ruby-on-railsFinding great examples of changes in web applications - versioning2 threads incrementing a static integer - c #Standards for using custom operators - standardsPass list by value - pythonCan I get out of a Windows application through wine? - pythonCreate unique number based on line input in javascript - javascriptAll Articles
I have a <div> element with a <p> element inside:
<div>
<p>
<div style="font-size:10pt; color:red;"> This is my Parent Div. <p>This is my Child Paragraph.</p> My parent Div Ends Here. </div>
How can I prevent my paragraph from inheriting CSS properties set in a <div> ?
In your case, the best way is simply over the styles that the <p> element inherits:
So, in your CSS file, which you should use instead of inline styles:
.parent-div { font-size: 10pt; color: red; } .child-paragraph { font-size: 12pt; color: black; }
In your child, node -
<p style="font-size:12pt; color:black;">This is my child</p>
Just set the inline style to whatever you want.
You can use the > selector in CSS to select the immediate child p of the div .
>
p
div
Script Link
div > p { font-size:1.2 em; color: green; }
Source: https://habr.com/ru/post/1468878/More articles:Multiple Stub Requests with webmock / rspec - ruby | fooobar.comhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1468874/split-string-with-commas-to-new-line&usg=ALkJrhgkOoBrarHbSxy8ZvG0tvxHaRJTtASQL merge function without specifying column names - mergeCan't resolve options? - ruby-on-railsFinding great examples of changes in web applications - versioning2 threads incrementing a static integer - c #Standards for using custom operators - standardsPass list by value - pythonCan I get out of a Windows application through wine? - pythonCreate unique number based on line input in javascript - javascriptAll Articles