CSS Master

(Primo) #1

Chapter 7 Applying CSS Conditionally


7. Applying CSS Conditionally


Asitsnamesuggests,conditionalCSSreferstoCSSrulesthatareappliedwhena
conditionismet.ConditionalCSSconsistsofconditionalgroupingrules,andthe
rulesetsnestedwithin.AconditioninthiscontextmaybeaCSSpropertyandvalue
combination,[email protected]
conditionsuchaswidth,[email protected]
featuresuchashoverstateorpointerinput,[email protected]'lldiscussall
thisinthechapter.


Both@mediaand@supportsaredescribedbytheCSSConditionalRulesModule,
Level 3 specification.^1 The@mediarule—whichyouprobablyknowasmedia
queries—isfullydefinedbytheMediaQueriesspecification.^2


Ofthetwokindsofgroupingrules,@mediaenjoysthebroadestsupport.Everymajor
browsersupportsthefeaturequeriesdefinedintheLevel 3 versionoftheMedia
Queriesspecification.^3 Mostcurrentlyusedbrowsersalsosupportitsrelated
JavaScriptAPI,matchMedia().SupportforLevel 4 featurequeries,however,isless


(^1) http://dev.w3.org/csswg/css-conditional-3/
(^2) http://dev.w3.org/csswg/mediaqueries-4/
(^3) http://www.w3.org/TR/css3-mediaqueries/

Free download pdf