Jump to content


Photo

<div> tags


  • Please log in to reply
4 replies to this topic

#1 yana

yana
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationToronto, Canada

Posted 18 September 2006 - 03:47 PM

What is the difference between using ID and CLASS? Is it better to use one than another???
For example...

<div id="frame">...</div>  and <div class="frame">...</div>
#frame {
width:777px;
height:100%;
margin-right:0px;
margin-left:0px;
margin-top:0px;
margin-bottom:0px;
padding:0px;
text-align:left;
background-color: #FFF;
}

.frame {
width:777px;
height:100%;
margin-right:0px;
margin-left:0px;
margin-top:0px;
margin-bottom:0px;
padding:0px;
text-align:left;
background-color: #FFF;
}
Yana

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 18 September 2006 - 03:54 PM

id should only be used ONCE, class can be used many, many times, in the same file.
Legend has it that reading the manual never killed anyone.
My site

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 18 September 2006 - 04:04 PM

id should only be used ONCE, class can be used many, many times, in the same file.


and, in addition to that, each element can only carry one id, but each tag could hold many, many classes as well
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 yana

yana
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationToronto, Canada

Posted 18 September 2006 - 04:08 PM

What do u mean by "each element can only carry one id"???

Something along these lines?? <div id="test"> is correct but <div id="test" id="test2"> is incorrect...while <div class="test"> is correct and <div class="test" class="test2"> is correct as well????????
Yana

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 18 September 2006 - 04:15 PM

actually, it's this: the following two lines show how to apply a single id and multiple classes
<div id="myID"></div>

<div class="red bold someStyle"></div>

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users