CSS Master

(Primo) #1
<!--[if IE 9]>
<link rel="stylesheet" href="ie9.css" type="text/css">
<![endif]-->

Abetterapproach,however—particularlyifyoustillneedtosupportInternetEx-
plorer 8 —istoaddtheless-thanorequal-tooperator:

<!--[if lte IE 9]>
<link rel="stylesheet" href="ie.css" type="text/css">
<![endif]-->

ConditionalcommentsaredeprecatedinInternetExplorer10+;theyaren’tavailable
instandardsmode.Thatbringsustoourotherapproach.

Using CSS Parsing to Our Advantage


AnotherapproachtosupportingolderbrowsersisinherenttoCSS.Wecantake
advantageofCSSerrorhandlingandthecascadetodefinestylesforolderbrowsers.
ThismethodreliesontworulesofCSSparsing:

1.Thelastdeclarationparsedistheonethat’sused.
2.Ifabrowserfailstounderstandarule,itwillignoreit.

Inotherwords,wecanprovideafallbackvalueandanenhancedvalueforaproperty.
Thebrowserwillchoosewhichtoimplementbasedonwhatitsupports.Here’san
example:

.title {
text-decoration: underline;
text-decoration: underline wavy #c09;
}

InbrowsersthatsupportCSS 3 text-decorationvalues,userswillseeawavypink
lineunderelementswiththetitleclass;inbrowserswithoutsupport,they’llsee
aplainunderline.TheserulescanexistwithinthesameCSSfileanddeclaration
block,butyoumaydecidetosegregatelegacyrulesintheirownfilesothatthey
canberemovedasyouraudienceadoptsnewerbrowsers.

Nowthatwe’vediscussedthebasicsofCSSfilestructureandlegacybrowserman-
agement,let’slookatsomeCSSarchitecturetechniques.

76 CSS Master

Free download pdf