css id vs class attributes, when to use id and when to use class, difference between id and class



css3 id vs class attributes,
when to use id and when to use class,
difference between id and class in css
css benefits of using class over id, css3 benefits of using id over class, html id vs class, css id vs class, html class vs id, css class vs id, The Difference Between ID and Class, id vs class tutorial, difference between id and class tutorial,The Difference Between class and id
HTML5, CSS3 and JavaScript Tutorials , lessons with examples.
Techsith.com

script type="text/javascript" src="http://aos-creative.prf.hn/creative/camref:100l3Rd/creativeref:10l3694">

id vs class more of a design related question and its a very important one. Overall you will be using more classes then ids.

id: think of element that is unique. there is only one id per element. your html validateor would throw and en error if you do use it which means you will not be reusing the same style anywhere else. all the main containers in your HTMLs you should use id because you are not going to repete them . That doesnt mean that you cant use class there. advantage of using is for is as your main namespace. for css this way you can segregate work so your css doesn’t messup. for example #leftContainer .button { color:red} which mean all the botton in the left containers are red.

class: you can used them freely. any common styles you can define as class. as you can have multiple classes for the same element. and mix and match of the classes will make your css small . for example you can create two divs with same color but diffrent font sizes.

Dont forget the attributes. actually id and class are attributes wich special meaning. and you can create your own custome attributes. like myattr. Platforms like angularjs uses them freely.

overall i thin its better to use classes then ids especially when you working in a team envirement where you are responsible for a partial html . using id can be riskier if someone else is using the same id in the other part of the html .

in css id has higher priority than class for example …..

source

Reply


Build A Site Info