HTML Selectors and CSS styling

HTML Selectors and CSS styling

CSS selectors are HTML-TAGS, which are normally used to formate an HTML document for a web browser.

Element selector

HTML tags: P, h1, h2, h3, h4, h5…

Eg

 p{ font-size : 12px; }

Class selector

A class is used to style a group of elements under a single class name. A ‘class’ name started with a period modifier, followed by the name of the ‘class’, .className.

Eg

.className p{ font-size : 12px; } .className h1{ text-color : red; } .className h2{ text-color : blue; }

ID selector

IDs are for a single unique element which should be identified as specified. A hashtag followed by the name of the ‘id’, #nameOfid.

Eg

#nameOfid{ width : 200px; height : 100px; } #one p{ text-color : red; } #two p{ text-color : blue; } #three p{ text-color : white; font-size : 24px; }