CSS Master

(Primo) #1
Figure 1.9. Using hyphenated attributes to style elements

Wecanalsouseitwithidnames;forexample,[id|=global]wouldmatch#global-
footer,#global-menu,andsoon.


Now,justbecauseyoucandosomethingdoesn’tnecessarilymeanyoushould.The
hyphenatedattributevalueselectorisidealforstylingdifferencesinlanguage.For
anyotherusage,though,you’ddojustaswelltouseaclassnameselector.Class
namesprovidealowerriskofunintendedeffectsinalargeproject.They’realsoa
mustifyourprojectstillrequiresInternetExplorer 8 support,sinceIE8doesnot
supportthisselector.


Matching Attribute Values by Substring


Wecanalsoselectelementswhentheattributevaluesmatchaparticularsubstring.
Threecharactersequencesletusmatchelementsdependingonwhetherthissub-
stringsitsatthebeginning,end,orelsewhereintheattributevalue:


^= matcheswhenthesubstringsitsatthebeginningofthestring.


Selectors 17

Free download pdf