| SitePoint Sponsor |

Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work


No.
Let's say you have these CSS rules,
Code CSS:.section ul {list-style-type:square} .nobullet {list-style-type:none}
Then you have this markup,
Your list items will have square markers, even though the list has class="nobullet". The reason is that the first rule has higher specificity (0,0,1,1) than the second (0,0,1,0).Code HTML4Strict:<div class="section"> <ul class="nobullet"> <li>First</li> <li>Second</li> <li>Third</li> </ul> </div>
In this case you could change the selector in the second rule to ul.nobullet to increase its specificity to 0,0,1,1. Since the second rule comes after the first rule, it will be applied.
My point was that one reason for including an explicit type selector in this type of rules is to increase the selector's specificity.
Birnam wood is come to Dunsinane


If they were bad enough to put .ul_nobullet, they'd probably have .ol_numbers
I include the element type if I'm using it on a particular tag... much easier when scanning the stylesheet quickly. I also have everything upfront, so I know whether I need to re-use that class or not however, which is a different scenario to not knowing what'll be on other pages.

Sleep deprovation. I thought that the HTML was set up like <ul class="section">.
Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work
Just on another note, I often use more than one class on the body tag when I am styling menu lists. The list can be the same html on each page but styled differently on each page by using those classes. Very handy.

Hello A(a)rem, nice to see you came over here. Love my post count?
Anyway shouldn't just one class on <body> be sufficient? Why would you need 2 or more classes for a page?
Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work


They can be used independently for different things. For instance, one class can be used to describe the subsection of the site where the page is (for highlighting the current nav menu item) while another can indicate whether the page has a column of related information.
Code HTML4Strict:<body class="news related">Code CSS:.home #home, .news #news, .about #about { /* style for current nav menu item */ } #wrapper {margin:0 0 0 12em} .related #wrapper {margin-right:14em}
Doing this with a single class will require several different classes (six for the simple three-section site in my contrived example) and will lead to severely and unnecessarily bloated CSS.
Birnam wood is come to Dunsinane

In all the coding sites I've done I have never done classes on body tag. I used to find it redundant..
Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work
It just allows for come very efficient coding. Look at the Happy Cog site, for example. Click on News, for example, and on the news page the News tab is white. Yet the menu code remains the same. Doing this means you can use php includes on menus, yet have a menu styled differently on each page.

Yes lol. I love this more because I can act myself, not a 60 year old man. Hell there are like 4 Kravvitz's here.
Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work


Two options.
Function
Basically, gets the page name, strips the .php, then if the page called is the current page it echos class="current".PHP Code:<?php
function currentPage($page) {
$file = basename($_SERVER['SCRIPT_NAME']);
$file = substr($file, 0, -4);
if($file==$page) echo ' class="current"';
}
?>
<li<?php currentpage('index'); ?>><a href="index.php">home</a></li>
Name
At the top of every page give it a name. Such as $page="about". Then call it in the menu:
<li<?php if($page=="about") echo ' class="current"'; ?><a href="#">About</a></li>
Works nice for simple sites. I always use PHP includes for easy maintainability. Not the best solution for anything that's big as it's all done manually, in that case a CMS is better.
Great answer! Thanks so much rochow. I'm still learning PHP, but will digest this bit by bit. The name option looks closest to the CSs option, but on first inspection, looks even simpler. Well done!




whats the differenence between these two ?
ul.nobullet {...}
.nobullet ul {...}
Im confused
first selects all unordered lists with a class name equal to nobullet. The second selects all unordered lists that are a descendant of any element with a class name nobullet.
<ul class="nobullet">
</ul>
<div class="nobullet">
<ul
</ul>
</div>

ul.nobullet means that a <ul> has a class of nobullet.whats the differenence between these two ?
ul.nobullet {...}
.nobullet ul {...}
Im confused
Example: <ul class="nobullet">
.nobullet ul means that a parent element of <ul> has a class of nobullet.
Example: <div class="nobullet"><ul>....</ul></div>
Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work



It's just my way of talking, I always say parent element when I refer to an acestor.
Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work


Just thought I'd clarify things, in case someone who doesn't talk the way you do happens to find this thread some time in the future.![]()
Birnam wood is come to Dunsinane
I've never used this before, and I totally forgot that I was able to do this!
Hopefully I can implement this the next time I'm coding something up!
Thanks for reminding me! :P

I never say ancestor element because trying to remember grandparent element, etc would confuse me. I KNOW what I mean by parent element so if in the future you hear me talking like this treat it as a speaking disorder.
Twitter-@Ryan_Reese09
http://www.ryanreese.us -Always looking for web design/development work
Bookmarks