I created a new design with a nav element and a list as the basis of my navigation bar to try to be as semantic as possible. I’ve used CSS to style it so that it’s a horizontal list of navigation links. It’s encapsulated in a nav element and that is styled to have a black background and be flush with the top of the page and extend the width of the browser window.
I’ve reviewed the site in many browsers and the list is horizontal and displays as expected – even in IE9. However, in IE8 or below it is a vertical list in the top left corner of the page and there is no styling to the nav element at all. I’m using the HTML5 doctype so IE8 should be in standards mode.
Here is the HTML I am trying to style.
<header>
<nav>
<ol>
<li class="first"><a href="/#menu">Menu</a></li>
<li><a href="/#locations”>Location</a></li>
<li><a href="/#about”>About</a></li>
<li><a href="/book.html”>Book Us</a></li>
<li class="telephone">☎ 555 555 5555</li>
</ol>
</nav>
<img class="logo" src="/images/logo.png" style="vertical-align: middle;">
</header>
Here is the CSS I’m using.
nav {
font-size: 1.2em;
font-weight: bold;
text-shadow: 0 2px 6px #6e3000;
vertical-align: middle;
background-color: black;
background: -webkit-gradient(linear,left top,left bottom,from(#333),to(#111));
background: -moz-linear-gradient(top,#333,#111);
width: 100%;
border-color: rgb(216, 35, 42); /* red */
border-bottom-style: ridge;
border-bottom-width: medium;
overflow: hidden;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
nav ol {
padding-left: 5%;
padding-right: 5%;
margin-top: 0.5em;
margin-bottom: 0.5em;
list-style-type: none;
}
nav ol li {
color: rgb(251, 243, 161); /* orange */
display: inline;
white-space: nowrap;
margin: 1em;
text-align: left;
}
nav ol li.right {
float: right;
text-align: right;
}
nav ol li a {
color: rgb(251, 243, 161); /* orange */
text-shadow: 0 1px 2px #000;
text-decoration: none;
display: inline;
}
nav ol li a:hover {
/* background-color: rgb(175,30,30); */
text-decoration: underline;
}
nav li.telephone {
color: rgb(251, 243, 161); /* yellow */
text-shadow: 0 1px 2px #000;
}
And finally, here is the CSS Reset I’m using. It has a HTML5 display-role reset section for older browsers.
/* CSS Reset http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
It is not styling because previous to version 9 IE didn’t support for HTML5 tags such as
nav, and it doesn’t unknown tags. You can work around it using the HTML5 shiv. If you have use for the Modernizr library, it has the shiv built-into.