CSS SELECTORS

CSS Selectors:

CSS selectors are use to select and manipulate HTML elements.
CSS selectors allow you to "select" HTML elements based on their id, class, type, attribute, and more.

Class Selector:

The "Class" selector uses the "class" attribute of an HTML element.
To select elements with a specific class, write a period character, followed by the name of the class.
"Class" selector defines as a symbol "." (dot).

Example

.class {
    text-align: center;
    font-size: 18px;
}

id Selector:



The "id selector" uses the id attribute of an HTML element to select a specific element.
An id should be unique within a page, so the id selector is used if you want to select a single element.
An "id selector" defines as a symbol "#".

Example

#header {
    text-align: center;
    font-size: 18px;
}

The element Selector:

The element selector selects elements based on the element name.
You can select all <b> elements on a page like this: (all <b> elements will be red text color, with a text font size)

Example:

{
    color: red;
    font-size: 24px;
}

Share this

Related Posts

Previous
Next Post »