CSS Class Selectors



To apply a class style, use the class attribute in the tag.

<h3>Type</h3>
<ul class="catlist">
   <li>Type A</li>
   <li>Type B</li>
   <li>Type C</li>
   <li>Others</li>
</ul>  

The CSS class selector allows you to select the class of the page element to apply style sheet. The class selector is identified by a dot(.) symbol followed by the class name.

.catlist {   
   color: #d51300;   
}  

The CSS style represents the page element of the class="catlist" , rendered with the font color #d51300. The class selector is applied in html


In this html code, the text inside <ul></ul> will be rendered as a #d51300 color. You can also define additional styles for one or more <li>.

As the example above shows, whenever the page element class="catlist", it will be apply the same style sheet, regardless of what type of page element it is.

Class selector will be applied to all of the page elements with the same class name, there are multiplexing effect, this is the difference with the ID selector.

The first character of the class name can not be a number.




Copyright 2014-2017 by DeveloperTut.com. All Rights Reserved.
TwitterGoogle+Facebook