Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 07-31-2010, 05: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?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

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!
 
 
Register now for full access!
Old 07-31-2010, 08: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, 05: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?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

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, 12:19 PM Re: CSS Form Question
racer x's Avatar
Ultra Talker

Posts: 457
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 11: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.14734 seconds with 12 queries