Try my app Expense Manager @ google play and amazon store.

Tuesday, May 8, 2012

CSS Beginner tutorial 7 : What is Class and ID Selectors

In the CSS, a class selector is a name preceded by a full stop (.) and an ID selector is a name preceded by a hash character (#). It might look like as follows.

#top {
background-color: #cccccc;

.intro {
color: red;

The HTML refers to the CSS by using the attributes id and class. It could look something like as follows.

<div id="top">

<p class="intro">This is my text.</p>


The difference between an ID and a class is that an ID can be used to identify one element, whereas a class can be used to identify more than one. You can also apply a selector to a specific HTML element by simply stating the HTML selector first, so p.desc will only be applied to paragraph elements that have the class 'desc'.

No comments:

Post a Comment

Follow by Email

Google+ Badge