Friday, 20 December 2013

CSS3 Difference between ID Selector and Class Selector.

POINT1:

ID Selector Must be Unique between Elements.
     Example: If we have 10 text boxes in a page. for each text box, we have to created unique ID.
                     <input type="text" id="firstinput">
                     <input type="text" id="secondinput">
                                            .
                                            .
                                            .
                                            .
                      <input type="text" id="tenthinput">

CLASS Selector can be used for Multiple Elements.
   Example: If we have 10 text boxes in a page and if we want to apply red color for 5 text boxes and green color for another 5 text boxes, we can able to create 2 classes and use them for 10.
                     <input type="text" class="redcolor">
                     <input type="text" class="redcolor">
                                            .
                                            .
                                            .
                     <input type="text" class="greencolor">                                            .

                     <input type="text" class="greencolor">


POINT2:

ID Selector: We can able to add only one ID for one HTML Element.
          Example: <div id="myexamplediv">

Class Selector: We can able to add multiple Classes for one HTML Element.
         Example: <div class="contentcss changeredcolor floatatright">


No comments:

Post a Comment

Thank you so much for providing your valuable feedback. I will will look into them and update my skills & technologies accordingly.