css - can I use body two times? -
i have css file div styles , css has body, this:
css1.css
body{ background-color:#000; } #div1{ ... } #div2{ ... }
in page want use divs in css1.css different body color. create css this:
css2.css
body{ background-color:#fff; }
so in page have:
<link rel="stylesheet" type="text/css" href="css1.css"> <link rel="stylesheet" type="text/css" href="css2.css">
css1.css has body , css2 too, right? can have problem doing this?
yes can!
although may need @ css selector specificity: https://developer.tizen.org/dev-guide/web/2.3.0/org.tizen.mobile.web.appprogramming/html/guide/w3c_guide/dom_guide/html_priorities_css.htm. here more illustrated resource:
from https://css-tricks.com/specifics-on-css-specificity/
the specificity depends on number of tags, ids, classes, pseudo-classes etc contained in selectors. if there tie between selectors order matters.
those 2 selectors (for body) have same specificity (=0001) second 1 override common properties of first.
or in other words body background-color #fff :). if useful different question.
Comments
Post a Comment