Class Selector: .

Pattern:

element.CLASSNAME

 

Definition:

The element.CLASSNAME selector matches every element that have a class attribute containing CLASSNAME. The CLASSNAME must immediately follow the ".". 

When representing the class attribute, element.CLASSNAME and element[class~=CLASSNAME] have the same meaning.

 

Examples:

Assign styles to all elements with class="code"

*.code { font-family: monospace; }

or simply

.code { font-family: monospace; }

Style all <p> elements with class="note"

p.note { color: yellow; }

Style every <p> element whose class attribute has been assigned a list of whitespace-separated CLASSNAMEs that includes both animal and sky

p.animal.sky { color: skyblue; }
w10schools
2014-11-10 05:21:50
.
Comments
Leave a Comment

Please login to continue.