2 replies [Last post]
n8gz4ez
n8gz4ez's picture
User offline. Last seen 1 year 31 weeks ago. Offline
rank Leader
Leader
Timezone: GMT-6
Joined: 2005-06-13
Posts: 802
Points: 0

I have been reading a lot about CSS menus, and made a few for myself.

What is the advantage of using <ul> and <li> tags rather than <p> tags for horizontal menus? Is this because the <ul> tag acts as a container?

From a markup standpoint without CSS, it seems to make more sense to use the <p> tag so that the menu is actually horizontal, especially if one were has a "A-Z" type menu.

Just curious. . . Thanks

This is my big chance . . . yep, I blew it . . .

Chris..S
Chris..S's picture
User offline. Last seen 8 hours 9 min ago. Offline
rank Moderator
Moderator
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6047
Points: 130

horizontal menus / &lt;ul&gt; versus &lt;p&gt; question

its more about semantics. A menu is usually an un-ordered list of links, so it makes sense to use the html markup for lists - <ul> <li>. In so doing you will have all the necessary elements to style your list.

<ul id='menu'>
  <li><a href='#'>link</a></li>
  ...
</ul>

#menu {...}
#menu li {...}
#menu a {...}
#menu a:hover {...}

Using a <p> will surely work. As will using <a> with a style of display:block. Although both of these will almost certainly require an aditional container to properly target styles at the menu elements.

n8gz4ez
n8gz4ez's picture
User offline. Last seen 1 year 31 weeks ago. Offline
rank Leader
Leader
Timezone: GMT-6
Joined: 2005-06-13
Posts: 802
Points: 0

horizontal menus / &lt;ul&gt; versus &lt;p&gt; question

Thanks for the reply Chris S. -- Semantics are a good enough reason for me. Seems like <ul> tags can save headaches the more complicated the menus are.

This is my big chance . . . yep, I blew it . . .