Hi all - I am new to the forum and web development so any help would be appreciated.
I am trying to create a vertical navigation bar using a div and li requirements. I can’t figure out why the list items are off center from the div. The example is at http://urbanfarmhouseonline.com/testmisc
and I will post the markup below.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“Content-Style-Type” content=“text/css; charset=utf-8” />
<title>New Web Project</title>
<style type=“text/css”>
That’s exactly what I wanted, but I’m a little confused by <ul id=“services_nav” >
I thought you had to specify the ul characteristics in the css e.g. #nav_services ul { …etc
It looks like you just created a ul then assigned it characteristics of a div class . Guess I didn’t know you could do that. You mention ul is a block level element - does that mean li is inline?
And one more question - how did you post the markup in a code box on this forum?
If you click on the “Go Advanced” button below the reply box, it will bring up an interface with more options. You can use the # button on the panel to wrap
tags around the selected text, or you can use the Syntax drop-down menu to choose specific code types like HTML, CSS, etc. You can also type the
tags by hand. Remember to put a / in the closing one, like any HTML tag. (If I type one as a demo, it will assume all the enclosed text is code, and display that rather than the tags. )
It looks like you just created a ul then assigned it characteristics of a div class .
Actually I REMOVED your DIV, keeping the UL you already had and joined the style that you had given the div with the UL. this whay i meant by :
Dont wrap UL in DIVs unless is absolutely necessary, as a UL is already a block element
Generally speaking, when coding… less= better.
No, <li> is also a block level element.
However you must remeber that OL and UL can only have LIs as direct children. This is done for semantic reasons.
What I was trying to get at is that you can stream line your code when possible. Lets say you had content tat you knew as going to be a single paragraph of text. If you can it is better to do this <p class=“example”></p> than this <div class=“example”><p><p></div>. in your example, I saw no reason for the DIV to wrap around the UL , I got rid of it.