CSS Tutorial
CSS selectors are used to select the content HTML elements you want to style.
There are several different types of selectors in CSS.
The element selector selects the HTML element by name.
HTML <p> elements are affected by the CSS properties.
Code Always.
Code Always To Become Best Programmer.
CSS Element Selector
The id selector uses the id attribute of an HTML element to select a specific element.
Id is always unique within the page so it is chosen to select a single, unique element.
To select an element with a specific id, write a hash (#) character, followed by the id of the element.
HTML with id #para1 elements are affected by the CSS properties.
Code Always.
Code Always To Become Best Programmer.
CSS Element Selector
The class selector selects HTML elements with a specific class attribute. .
To select an element with a specific class, write a dot (.) character, followed by the class of the element.
HTML with class header_paragraph elements are affected by the CSS properties.
Code Always.
Code Always To Become Best Programmer.
CSS Element Selector
The universal selector selects all the elements on the pages.
To select an all elements, write a dot (*) character.
All HTML elements are affected by the CSS properties.
Code Always.
Code Always To Become Best Programmer.
CSS Element Selector
The grouping selector is used to select all the elements with the same style definitions.
Look at the following CSS code (the h4, and p elements have the same style definitions):
HTML with h6 and p1 elements are affected by the CSS properties.
Code Always.
Code Always To Become Best Programmer.
CSS Selectors
Selector | Example | Description |
---|---|---|
.class | .header | Selects all elements with class="header" |
#id | #definition | Selects the element with id="definition" |
* | * | Selects all elements |
element | p | Selects all <p> elements |
element,element,.. | div, p, h4 | Selects all <div> elements and all <p> elements and all <h4> elements |