PDA

View Full Version : Code opinion about navigation



redelite
June 2nd, 2008, 03:35 PM
So I was working on a website for a client and I got to the point to where I'm going to code the main navigation. It is going to be a horizontal bar underneath the header with 6 links.

Before I started to write the HTML for it, I stopped for a second and thought, should I use an unordered list and float them or should I just use anchor tags with padding?

So ultimately, my questions is, on a horizontal navigation, do you personally use an unordered list or not?

BTW, I went ahead and used an unordered list, incase you were wondering.

*cheers* :beer:

fasterthanlight™
June 2nd, 2008, 04:00 PM
unordered list, yo!

depending on the styling you can either define your list items as blocks and float each one, or you could just do display: inline on the list items ....... I prefer the block + float method as opposed to the inline method

redelite
June 2nd, 2008, 04:05 PM
True, but it seems like a useless amount of extra code.. Although, come to think of it, it would be much better to have that list then to NOT have the list if you decided to provide multiple layout stylesheets :thumb2:, so I guess I pretty much answered my own question.. :shifty::puzzle:

fasterthanlight™
June 2nd, 2008, 04:08 PM
Well either way you're going to have to code a lot of code, but its all about the maintainability -- looking forward -- and how easy it would be to add a link to the nav, or remove one, and <ul></ul> does this very well.

best article on lists ever: http://www.alistapart.com/stories/taminglists/
best article on sprites ever: http://www.alistapart.com/articles/sprites

and as for multiple stylesheets, it doesn't how you set the structure up with the code, if you've done a good job you'd be able to do this no matter what technique you use... as to truly utilize CSS's powers you strip all of the visual aspects of a page out from the structure.

redelite
June 2nd, 2008, 04:17 PM
Yeh, I understand all that. I mean you can easily add a link to the nav if it was just a div (container) with some anchor tags in it as well.

I guess it was a stupid question, nevermind. :P

I was just wondering what people's opinion was on it is all.

fasterthanlight™
June 2nd, 2008, 04:18 PM
Golden Rule of Internets: Do not use a div if you do not have to

divs are like, last resort. (well, for this purpose anyways, using divs for a bunch of little things like nav items is just as bad as using tables for layout)

redelite
June 2nd, 2008, 04:24 PM
Ouch! :( :P Gotcha.. I'll post-it that one up for the next time I make a layout and I say "ok, one div for header, one for nav with an unordered list, one for content, and one for footer with unordered list".. and ill just go with: <h1><ul><div content><ul> instead :thumb2:

fasterthanlight™
June 2nd, 2008, 04:55 PM
BOoyah!

although i still make a nav div, because sometimes (err.. most of the time) you need to position your ul around within something

Raydred
June 2nd, 2008, 08:39 PM
So I was working on a website for a client and I got to the point to where I'm going to code the main navigation. It is going to be a horizontal bar underneath the header with 6 links.

Before I started to write the HTML for it, I stopped for a second and thought, should I use an unordered list and float them or should I just use anchor tags with padding?

So ultimately, my questions is, on a horizontal navigation, do you personally use an unordered list or not?

BTW, I went ahead and used an unordered list, incase you were wondering.

*cheers* :beer:


I personally like unordered lists. The reason being, if you wanted to add another item, it's really quick and easy to style. I guess you could argue, that setting up padding and putting a < br > is just as fast, but I like that the links are Contained within the unordered list, making it very easy to style later.

Hope that helps! :goatee:

fasterthanlight™
June 2nd, 2008, 10:23 PM
plus you can trick yer ul's out like how i do