html - What is the difference between these two selectors -
is there difference between this
#id { }
and this
div#id { }
yes. there 2 differences:
the first selector matches element id="id"
, while sec matches div
elements id.
the sec selector more specific, if have both , match same element, styles sec have precedence.
normally utilize first selector. id should unique in page target single element.
the sec selector useful if utilize same style sheet several pages, , either want target id under conditions, or if want override rule making more specific.
html css difference
No comments:
Post a Comment