I'm trying to understand how wildcard selector in CSS does work? Consider the following HTML markup:
<div id="child"> </div> And corresponding CSS:
div[id="child"] {border-color: green; } #child{ border: 20px solid; background: aqua; height: 50px; margin: 10px; } I think, that style of div.child will be:
border: 20px solid; background: aqua; height: 50px; margin: 10px; border-color:green; I.e. border-color:green just add to a stylesheet of div.child. But if we write
div[id="child"] {border-color: green!important; } #child{ border: 20px solid; background: aqua; height: 50px; margin: 10px; } It works like
#child{ border-color: green; border: 20px solid; background: aqua; height: 50px; margin: 10px; } Question: Why we must using div[id="child"] {border-color: green!important; } rather than div[id="child"] { border-color: green } for applying green color for border?
*).