CSS element Selector

CSS element selector selects all the elements with the specified element name. CSS styles written under the element selector affect each and every element that matches the specified element name.

In the example below, the element selector selects all the <p> elements on the page and applies the same styles to each of them. Try it out to see how it works:

Example:

p{
    background: yellow;
    border: 2px solid blue;
    padding: 5px;
}

In the example below, the element selector selects all the <div> elements and applies a yellow background to each of them. Try it out:

Example:

div{
    background: yellow;
}

CSS Element Selector Syntax

The element selector has the following syntax:

element{
    CSS styles
}

Related Pages

CSS Tutorial: CSS Selectors