Friday, 20 December 2013

Friday, December 20, 2013
ID anc classIf you have used 'id' and 'class' before for other purposes for identifying certain selected elements then it will be pretty easy for yo to grasp the idea of 'id' and 'class' in CSS. 

We are assuming that you have already gone through the previous tutorials. We advice everyone to go through the previous tutorials. If you are already familiar with CSS and its syntax than you can afford to skip to this tutorial.


Id Selector : 

 Let us simplify the purpose of the id selector. Remember the following points.
  • The id selector is used when you have a single, unique element to style.
  • The id attribute of the HTML element is used by the id selector.
  • The id selector is defined with a "#" symbol.
  • Never begin an id name with a number.
Let's see an example:
#aji_para
{
    text-align:left;
    color:blue;
}

Class Selector : 

Now we will look into the class selector. Remember these points.
  • Class selector is used for specifying a style for a group of element. 
  • The class selector can be used on more than one element.
  • The HTML class attribute is used by the class selector.
  • The class selector is defined with the '.'
  • Class names do not begin with a number.
Let's see an example :

.justify {text-align:justify;}
p.center {text-align:center;}
Now we will use all that we have learned till now and create a style for a HTML document and see the result of it.



We hope you enjoyed this tutorial and it was helpful to you. If you liked it then please do share it with others. Also, if you are really into programming and want to join our Facebook Group then do visit our group :

0 comments:

Post a Comment