Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.

Closed Thread
Thread Tools Display Modes
Share |
Old 10-15-2014, 03:15 AM
SGInteractive SGInteractive is offline
Junior Member
Join Date: 02-18-14
Location: Singapore
Posts: 30
iTrader: 0 / 0%
What is the difference between a class and id in HTML

Hi guys

Do you Know About difference between a class and id in HTML...?



Old 10-15-2014, 03:28 AM
quickscrum quickscrum is offline
Junior Member
Join Date: 08-19-14
Location: Paris, France
Posts: 31
iTrader: 0 / 0%
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.

Example : <a href="#content">Go to the content</a>


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.


<div class="left larger">
<p>A tiny bit of content.</p>
Old 10-15-2014, 03:41 AM
Veeramanikandan Veeramanikandan is offline
Junior Member
Join Date: 07-14-14
Posts: 13
iTrader: 0 / 0%
Normally the id can mention with "#" and the Class mention with "." indicator.

The ID can be used once in a setion or div. But the class can call more than one time anywhere inside the program
Old 10-18-2014, 11:26 AM
Avocado Plugins's Avatar
Avocado Plugins Avocado Plugins is offline
Contributing Member
Join Date: 06-23-14
Location: Boston
Posts: 70
iTrader: 0 / 0%
Simplest explanation is this - class is to identify a broader range of elements whereas an id is for identifying a more specific element.

An example could be this: You have a class called UIElements and that identifies all of your form elements including buttons, check boxes, radio boxes and such, then you have IDs for each elements let's say for buttons you have UIButton and for radio boxes you have UIRadio and so on and so forth it just allows you to select more easily when you want to - that's all.
Old 10-24-2014, 10:28 PM
confidence123 confidence123 is offline
Contributing Member
Join Date: 10-10-14
Posts: 54
iTrader: 0 / 0%
Class and id is used for calling CSS.

when we use like,
so we use class for this css calling like <p class="Header">

and we use like

so we can use this types csss calling like <p id="header">

i hope u r understood.
Old 11-18-2014, 04:12 AM
chamath chamath is offline
Junior Member
Join Date: 11-17-14
Posts: 14
iTrader: 0 / 0%
Thumbs up

Simply - ID is unique and cannot use more than one in same but Classes can use wider and you can use same class to any number of elements.

ID's are unique
  • Each element can have only one ID
  • Each page can have only one element with that ID

Classes are NOT unique
  • You can use the same class on multiple elements.
  • You can use multiple classes on the same element.
Old 11-18-2014, 07:38 AM
TechBuddy1 TechBuddy1 is offline
Contributing Member
Join Date: 11-04-14
Posts: 51
iTrader: 0 / 0%
Use IDs when there is only one occurence per page. Use classes when there are one or more occurences per page.
Go Back   Webmaster Forum > Web Development > Coding Forum

Closed Thread

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Div and Class difference fradlong Coding Forum 11 11-24-2014 11:00 PM
what is the difference between HTML and XML sitemap ? vicky bob Google Forum 2 03-27-2014 08:44 AM
Difference between table and Div in html zohail Coding Forum 9 03-04-2012 07:09 AM
Difference bet ID and class CSS http Coding Forum 1 12-07-2006 08:40 PM

V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory

All times are GMT -7. The time now is 05:01 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC