Forum Moderators: not2easy

Message Too Old, No Replies

Problem with Spacing between Links

Links are too close together

         

chillbill

10:13 pm on Aug 7, 2008 (gmt 0)

10+ Year Member



Hello, I am trying to get my navigation worked out. I have a problem with the links not having enough space between them. They appear too close together, so I am sort of stuck. Also I used the Draw AP DIV mode in Dreamweaver, is it okay to use it for layouts? I am also more of a beginner with CSS. Here is the code Thanks Bill

HTML

<div id="headernav">
<a href="index.html">Home</a>
<a href="animation.html">Animations</a>
<a href="illustration.html">Illustrations</a>
<a href="clients.html">Web Sites</a>
<a href="form.html">Contact</a></div>

CSS

#headernav {
position:absolute;
left:338px;
top:85px;
width:406px;
height:23px;
z-index:0;
font-size: 14px;
font-style: normal;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
padding: 0px 4px 4px 4px;
margin: 2px 4px;
text-align: right;
}
#headernav ul {
padding: 2px 0 4px 0;
margin: 0;
}
#headernav p {
padding: 40px;
margin: 10;
color: #FFFFFF;
background-color: #FFCB05;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #FFFFFF;
}
#headernav ul li {
padding: 4px;/*2px 4px 2px 2px;
margin: 0;
display: inline;
}
#headernav a {
color: #fff;
text-decoration: none;
}
#headernav a:hover, #footer a:focus {
text-decoration: none;
color: #FFD34B;
}

Xapti

1:28 am on Aug 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure what "Draw AP div mode" is, but looking at the documentation, or a chat/forum oriented towards DW would be a good idea to find out more about that (assuming someone doesn't happen to help you).

One problem with the code you gave, was either not enough HTML (unlikely), or too much CSS. You gave style information for lists and paragraphs (ul, li, p), but they are not existant on the HTML example.

Your navigation is not in list format. This is somewhat of a neutral thing, but most people recommend that you wrap a UL around your navigation, and add li around each anchor element (link). This is mostly just for semantic reasons AFAIK.

Anyways, to space elements out in web design, people use CSS properties called padding and margins.
You should check the W3Cs explanation of the box model for details about them (http://www.w3.org/TR/REC-CSS2/box.html), but the basic different is that margins are used to separate, and padding is used to, well, pad. You could use either vertical padding or a vertical margin to space your links, but you should probably use a bit of both (such as 2px padding, 5px margin or something).

dreamcatcher

9:13 am on Aug 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to space them out, use a none breaking space:

&nbsp;

dc

chillbill

1:57 am on Aug 12, 2008 (gmt 0)

10+ Year Member



I was able to get just the right results with a nbsp; but is it the best way to correct the problem. I thought that the style sheet was suppose to control that. I wan the navigation to be right, because it is my portfolio site.

D_Blackwell

8:59 pm on Aug 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Xapti makes good points. I don't nothin' 'bout that DW stuff but your CSS definitely doesn't match up to well with the HTML for the example. I would wrap the <a> in a list, but it isn't necessary. <dd> can be a handy tool.

You can add a bunch of &nbsp; - however many you need, but easier to just use margin or padding on the <a>

#headernav a {
color: #000;/*#####Color change*/
padding-right: 10px;
text-decoration: none;
}

You'll learn a whole lot more about code writing from scratch than hacking in fixes - IMO. I don't know how #headenav fits into the page, but if it isn't perfect it may be the source of more problems due to the positioning and such.

<html>
<head>
<style>
#headernav {
position: absolute;
left: 338px;
top: 85px;
width: 406px;
height: 23px;
z-index: 0;/*#####Needed?*/
font: normal 14px Arial, Helvetica, sans-serif;/*#####Shorthand*/
text-decoration: none;
padding: 0px 4px 4px 4px;
margin: 2px 4px;
text-align: right;
}
#headernav ul {
padding: 2px 0 4px 0;
margin: 0;
}
#headernav p {
padding: 40px;
margin: 10px;/*#####10 what?*/
color: #fff;
background-color: #ffcb05;
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
}
#headernav ul li {
padding: 4px; /*2px 4px 2px 2px;*//*#####Partial comment?*/
margin: 0;
display: inline;
}
#headernav a {
color: #000;/*#####Color change*/
padding-right: 10px;
text-decoration: none;
}
#headernav a:hover, #footer a:focus {
text-decoration: none;
color: #ffd34b;
}
</style>
</head>
<body>
<div id="headernav">
<a href="index.html">Home</a>
<a href="animation.html">Animations</a>
<a href="illustration.html">Illustrations</a>
<a href="clients.html">Web Sites</a>
<a href="form.html">Contact</a>
</div>

<!--#####
Hello, I am trying to get my navigation worked out. I have a problem with the links not having enough space
between them. They appear too close together, so I am sort of stuck. Also I used the Draw AP DIV mode in
Dreamweaver, is it okay to use it for layouts? I am also more of a beginner with CSS.
-->
</body>
</html>