answersLogoWhite

0


Best Answer

An ID is used to define the style properties of a specific thing whereas a class is used to define something you may use multiple times. For instance, if you are going to make a loginbox you will use an id because you will only have one identical loginbox on the page whereas if you wanted every quote to be given the same style you would use a class, this would mean all elements with class=quote (after you define it in the CSS) would always style quotes to your needs. In short, you could use either as they have pretty much the same outcome, but organised CSS is good CSS so you are better off using classes and ID's as i have defined them above.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

'Class' refers to a set of CSS attributes that can be assigned to multiple divs to give them all the same attributes. If a user wanted to display 4 divisions of his page (lets say, 4 spots on his webpage where he displays images) with the same font and border, he would make a class in CSS (ex: class1) and give it the desired font and border attributes, but now all he would have to do for those 4 divs is assign it the class (<div class='class1'>). This way, if he decides to change his border or font type for some reason, he only has to go and edit that one class attributes, instead of having to go through and edit each individual div CSS. A class in CSS is created using .classname{}

'ID' is also like Class there is probably no difference, you can use ID the same way as a Class and assign CSS attributes to multiple div or elements, but after CSS3 you can assign multiple Classes to a single element by separating them with space but can't assign multiple Ids. Id is meant to be used for javascript, if want to do something with a div using javascript then you can point to that div using id. So its better to use Classes for CSS and ID for javascript.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

In HTML, the class attribute is an identifier used on one or more elements on a web page. On the other hand and ID is an identifier that is unique and applies to only one element instance. In other words, a class can appear on multiple elements throughout a single document whereas an ID can be used once and only once in the document. In CSS, a class selector is declared using the dot symbol (for example .class-name) whereas an ID selector is declared with an octothorpe (#) symbol (for example #id-name).

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

There are 2 ways to identify an element in HTML, ID and CLASS. Id can be referred by # and class by .

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Class tag and ID tag both are used for reference. Id tag is referred by # symbol while class by dot symbol.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between the Class attribute and the ID attribute in HTML and CSS?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between a period and a hash symbol in declaring CSS classes?

Period which specifies to a class using (.) or dot operator Where as hash or # specifies to id of a particular attribute of HTML tags


What is differences between tags and attribute?

A tag is a declaration of a HTML object whereas an Attribute is a property of an object.


How do you apply css code in HTML?

"class" is an attribute of most if not all HTML tags. To apply a CSS class to a tag, simply make the class attribute equal to that CSS class. For example, suppose you have a CSS class called bigRed that makes text large and red. If you want to apply it to a certain text, just put it in a tag surrounding that text. e.g. . . . but my &lt;span class='bigRed' &gt;car&lt;/span&gt; was faster than . . .


What is the fullform of REL in HTML?

The REL attribute in HTML is a shortened version of "relationship." REL attributes are used to define the relationship between one file and another.


What is the difference between an HTML page and a dhtml page?

DHTML combines HTML, JavaScript, the HTML DOM, and CSS.


What is the difference between html and dhtml in hindi?

hello


Which attribute specifies the name of the image to display in HTML?

There is an attribute which defines the name of the image to be displayed. The attribute is called as ALT or alternate.


The color of a hyperlink that has not been clicked can be specified by setting what attribute in the BODY HTML tag?

The color of a hyperlink that has not been clicked can be specified by setting the "BGCOLOR" attribute in the HTML tag.


How do you change HTML attribute using HTML dom?

You can change HTML attributes easily. Using Dom that can be done using JavaScript.


Is width a tag in HTML?

This is not a tag. It is an attribute and part of CSS


How do you align in HTML?

Align is an attribute included in the HTML format. You can align the position to be right, left or center.


What is the difference between DDR1 and DDR2?

http://dhivacpt.blogspot.com/2007/10/difference-between-ddr1-and-ddr2.html