CSS Id and Class

Class Selectors & The id :

In addition to placing a style for a HTML aspect, CSS lets you specify your own selectors named “identification” and “type “.

Id Selector :

The id selector is can be used establish a mode for a single, distinctive element.
The id selector uses the id attribute of the HTML aspect, and is identified with a “# “.
The model concept below will undoubtedly be placed on the aspect with id=”para1″:

Example:

#para1
{
text-align:center;
color:red;
}

Class Selector :

The class selector can be used to specify a style for a small grouping of elements. Unlike the id selector, the class selector is usually utilized on a few elements.
This enables you to set a certain type for most HTML aspects with the same class.
The class selector uses the HTML class attribute, and is defined with a “.”
In the example below, all HTML aspects with class=”middle” will be center-aligned:

Example :

.center {text-align:center;}


You may also establish that only specific HTML elements must certanly be afflicted with a class.
In the example below, all p elements with class=”center” will undoubtedly be center-aligned:

Example :

p.center {text-align:center;}




Posted in CSS

Leave a Reply

Your email address will not be published. Required fields are marked *