Click to See Complete Forum and Search --> : <a> border problems
theuedimaster
02-25-2007, 06:43 PM
I have a linkbar at the top of my page, composed of <a> elements in a <div>. I want to put a 1px border around my <a> elements, and I have successfully done this in firefox. IE, on the other hand, only puts borders on the left and right. I have tried manually formatting the top border, but that doesn't work either.
Also, I'd like to make my <a> elements have a specified width. If that's the wrong use of an <a>, what should I use instead to produce my linkbar? I looked on google and found this page: http://builder.com.com/5100-6371-5153115.html Should I use their list advice?
Also, padding works on firefox but not in ie. Yikes.
http://www.sigmaseven.net/knapp
felgall
02-25-2007, 07:28 PM
You can fix all of those by adding display:block to the stylesheet for those entries.
theuedimaster
02-25-2007, 08:53 PM
Well see, that's the problem. If I use block, I get a vertical link bar. I want a horizontal one.
felgall
02-25-2007, 10:27 PM
So then you float them next to one another.
Centauri
02-25-2007, 10:27 PM
The idea here is to have the <a> elements as blocks, set to specific sizes, then float the <li> elements left to sit everything on the one line.
HOWEVER, you have a nesting problem within your menu markup - the opening <a> tags should be BEFORE the href declaration. There is also no need for an inactive class, nor a separate holding div for the ul.
Setting widths and margins on the body element is not a good method to centre a layout - use a wrapper div instead. Whilst an <img> within the first <a> link displays the logo graphic ok, it means nothing semantically - the use of a styled <h1> header means more here.
Unless you intend to use specific features of xml (which has little support), then as per another post on these forums, a html 4.01 strict doctype and utf-8 encoding is more appropriate for new sites.
Taking all this together, I came up with this html : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Knapp Group</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="wrapper">
<h1><a href="index.php">Knapp Group</a></h1>
<!-- Links -->
<ul id="navbar">
<li><a href="index.php" class="activelink">Home</a></li>
<li><a href="trackrecord.php">Track Record</a></li>
<li><a href="inventory.php">Inventory</a></li>
<li><a href="faq.php">FAQ</a></li>
<li><a href="contactus.php">Contact Us</a></li>
</ul>
<!-- Footer -->
</div>
</body>
</html>
and this css : /* CSS Document for Knapp Project */
/* Basic Styling */
* {
margin: 0;
padding: 0;
}
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
a {
color: #666666;
font-weight: bold;
text-decoration: none;
border: none;
}
#wrapper {
width: 800px;
margin: 0 auto;
}
h1 a {
display: block;
height: 61px;
background-image: url(images/titlepic.gif);
font-size: 1px;
text-indent: -1000px;
}
#navbar {
overflow: hidden;
margin: 1px 0 0;
}
#navbar li {
list-style: none;
float: left;
}
#navbar a {
display: block;
width: 8em;
color: #666666;
font-size: 16px;
text-decoration: none;
background-color: #EEEEEE;
border: 1px solid #CCCCCC;
text-align: center;
}
#navbar .activelink, #navbar a:hover {
color: #333333;
font-weight: bold;
background-color: #CCCCCC;
}
Cheers
Graeme
sticks464
02-25-2007, 11:12 PM
I have redone your code for a nice horizontal menu using display block. Centauri has beat me to it but I'll post it up anyway.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Knapp Group</title>
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
width:800px;
padding:0;
margin: 0 auto;
}
#nav {
height: 24px;
}
#menu1 {
width:100%;
padding:0;
margin:0 auto;
list-style-type:none;
margin-top: 2px;
}
#menu1 li {
float:left;
width:150px;
border-right:3px solid #00f;
}
#menu1 a {
display:block;
width:150px;
color:#000;
font-weight:bold;
text-align:center;
padding:4px 0;
text-decoration:none;
float:left;
background-color:#999;
}
#menu1 a:hover {
background:#666;
color:#fff;
text-decoration:underline;
}
-->
</style>
</head>
<body>
<div id="header">
<a href="index.php">
<img id="titlepic" alt="Knapp Group" src="images/titlepic.gif" />
</a>
</div>
<div id="nav">
<ul id="menu1">
<li><a href="index.php">Home</a></li>
<li><a href="trackrecord.php">Track Record</a></li>
<li><a href="inventory.php">Inventory</a></li>
<li><a href="faq.php">FAQ</a></li>
<li><a href="contactus.php">Contact Us</a></li>
</ul>
</div>
</body>
</html>
theuedimaster
02-25-2007, 11:53 PM
Thanks for all the responses! You guys are great :).
theuedimaster
02-26-2007, 02:57 AM
I ended up actually using a combination of both of your codes for mine to work :). It looks the same in firefox, ie, and opera now, woot!