Reply
Old 07-31-2010, 04:32 AM CSS Form Question
MattGoucher's Avatar
Skilled Talker

Posts: 64
Name: Matt
Location: California
Trades: 0
When checking the source of websites I notice that in their CSS files, some of them make div's like this:
HTML Code:
div#header {

}
and other do it like this:
HTML Code:
#header {

}
What is the difference, are both accepted among the community? additional info?
__________________
Twitter | Portfolio & Blog | SEO Help | PM Me
Invalid Code On A New Website Is Like Having A New Car With A Broken Windshield
MattGoucher is offline
Reply With Quote
View Public Profile Visit MattGoucher's homepage!
 
 
When You Register, These Ads Go Away!
Old 07-31-2010, 07:24 AM Re: CSS Form Question
Siemen's Avatar
Average Talker

Posts: 17
Trades: 0
Simply test.
HTML code
Code:
<table>
<tr>
<td id="header"> Test </td>
</tr>
</table>

<div id="header">
Test
</div>
CSS CODE
Code:
DIV#header {
  background: #000000;
  color: #ffffff;
  width:500px;
  height:100%;
}
This style will work only for DIV, but not for table.. If you will want to work for both, you must remove "DIV" (remain #header)
Siemen is offline
Reply With Quote
View Public Profile
 
Old 08-06-2010, 04:56 AM Re: CSS Form Question
MattGoucher's Avatar
Skilled Talker

Posts: 64
Name: Matt
Location: California
Trades: 0
Is one way better than the other? Are they both browser compatible?
__________________
Twitter | Portfolio & Blog | SEO Help | PM Me
Invalid Code On A New Website Is Like Having A New Car With A Broken Windshield
MattGoucher is offline
Reply With Quote
View Public Profile Visit MattGoucher's homepage!
 
Old 08-07-2010, 11:19 AM Re: CSS Form Question
racer x's Avatar
Ultra Talker

Posts: 387
Name: Randy
Location: Northern Wisconsin
Trades: 0
Some people just like to remind themselves that ID is for a div. In most cases, "header" will be a div. Also, ID's cannot be duplicated on the same page, therefore, there is no advantage(as far as I know) to target it with adding "div".

These are also identical and both are browser compatable:
p#first-paragraph { }
#first-paragraph { }

If it were a general "class"(not ID), I'd probably target it more specifically such as:

span.text-shadow { }
rather than
.text-shadow { }

Only because you might have a slightly different styling for a paragraph that uses text-shadow(for example) that you wouldn't want to inherit stying from the span.text-shadow.

Last edited by racer x; 08-07-2010 at 10:29 PM..
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Reply     « Reply to CSS Form Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13162 seconds with 13 queries