what is different between id and classes
This is a discussion on what is different between id and classes within the Web Design forums, part of the Web Designing & Development category; what is different between id and classes...
what is different between id and classes
You can use an ID name once in any XHTML or HTML document to identify large segments of the site or important information, link, etc. while classes can be used multiple times in the same HTML document to classify areas with a specific property. 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 (#).
A class is used to define one or more elements based on some author-defined criteria.An id is used to define a unique element on a page. I find ids are most useful for structured page layout Id is uniquely identify an element on the webpage, irrespective of its type button, div, radio etc. where as Class is used to identify a certain type of elements.
Classes and IDs come from CSS. IDs are supposed to be unique within your HTML document classes can be used multiple times within the same document.ID, short for fragment identifier, is a beautiful attribute, but it's very easy to use them improperly.Classes, like ID's, can also be used to in JavaScript scripts, but unlike ID's, they can be used multiple times in the same HTML document.
[SIZE=2]ipad stylus [/SIZE]
Could you give an example of when you would ever really use id over class? I mean, id is limiting, while class is not. I understand what the difference is, but you could do everything about css not ever using id.
Basically what is the id's big selling point, and why does it even NEED to exist?
Hello Friends.........
ID, short for fragment identifier, is a beautiful attribute, but it's very easy to use them improperly. You can only use an ID name once in any XHTML or HTML document. Duplicate ID tags will cause your page to fail validation, and can have negative effects when using JavaScript with them. Simply put, an ID is like the sticker that says "you are here" on a mall directory, and there can only ever be one of those.
Classes, like ID's, can also be used to in JavaScript scripts, but unlike ID's, they can be used multiple times in the same HTML document. This separation of content from presentation is what makes sites powered by CSS more robust, but some don't know the full extent to which they can use classes.
Thanks
thanks for sharing this information.
ID is used to identify the name of object in page using that you can get object in javascript.
CSS I do not care that the signs are much higher than specific classes. This, of course, need to think in terms of CSS rules to replace the other in any number of style sheets.
There are lot of between Id & Classes. id can be used only once but classes can be used multiple. id can be used as hyperlink & class cann't be.