Reputation: 27
I have a simple question for you that I am not sure about. If a p tag has no CSS-code but the body tag has following code:
body {
background-color: white;
color: red;
font-family: "Calibri";
}
... I know that the p tag gets the color red and the font Calibri, but does the p tag get the background color
background-color: white
...or does it get no background-color?
Thanks!
Upvotes: 1
Views: 424
Reputation: 1905
The
<p>
tag gets thebackground-color
, if nobackground-color
is set for the<p>
tag.
For example:
HTML:
<p>test text</p>
CSS:
body {
background-color: red;
font-family: "Calibri";
}
Now you have background-color: red;
and no other background-color
is set for the <p>
tag so the <p>
tag gets background-color: red;
.
But if you set a background-color
to the <p>
tag, the background-color
of the <p>
tag is preferred.
HTML:
<p style="background-color: green;">test text</p>
CSS:
body {
background-color: red;
font-family: "Calibri";
}
So the result is:
Upvotes: 1