4 Replies - 341 Views - Last Post: 12 October 2012 - 11:02 AM

#1 dreamincodehamza  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: -12
  • View blog
  • Posts: 332
  • Joined: 12-September 08

id basic issue

Posted 12 October 2012 - 09:04 AM

ID should work only once but in below code is is changeing the color red to all.
Not sure what is going on here.


here is my code
<style>
	#hamza123 {
	 	color :  red	 ;
	}
</style>

<address id="myid">  text texttext texttext texttext texttext texttext text </address>
<p id="myid"> text texttext texttext texttext texttext texttext text </p>
<div id="myid">text texttext texttext texttext texttext texttext text  </div>




Is This A Good Question/Topic? 0
  • +

Replies To: id basic issue

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9199
  • View blog
  • Posts: 34,560
  • Joined: 12-June 08

Re: id basic issue

Posted 12 October 2012 - 09:13 AM

You keep giving it the same unique id. Use a class instead.
Was This Post Helpful? 0
  • +
  • -

#3 dreamincodehamza  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: -12
  • View blog
  • Posts: 332
  • Joined: 12-September 08

Re: id basic issue

Posted 12 October 2012 - 09:41 AM

View Postmodi123_1, on 12 October 2012 - 09:13 AM, said:

You keep giving it the same unique id. Use a class instead.

yeah i know that but what's the need of class if we can acheve the task using id.


i am not getting the logic of class n id the difference between them,,
making me confuse.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9199
  • View blog
  • Posts: 34,560
  • Joined: 12-June 08

Re: id basic issue

Posted 12 October 2012 - 09:44 AM

Browsers tend to be pretty lax about things, but standards are standards. There's no compiler to wag a finger at you for not doing the right thing. IDs are meant to be unique.. classes for a group of similar things. It makes for a bad readability and you may run into that browser update that enforces proper standards and then you are hosed.

End game and pull up those big boy pants and use the standards! :D
Was This Post Helpful? 0
  • +
  • -

#5 dreamincodehamza  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: -12
  • View blog
  • Posts: 332
  • Joined: 12-September 08

Re: id basic issue

Posted 12 October 2012 - 11:02 AM

View Postmodi123_1, on 12 October 2012 - 09:44 AM, said:

Browsers tend to be pretty lax about things, but standards are standards. There's no compiler to wag a finger at you for not doing the right thing. IDs are meant to be unique.. classes for a group of similar things. It makes for a bad readability and you may run into that browser update that enforces proper standards and then you are hosed.

End game and pull up those big boy pants and use the standards! :D

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1