RWDHTMLCSS.COM

Html & CSS Walkthrough

Previous Home Table of Contents Next

Position the small menu in the upper right hand corner of header.

HTML

<header>>
<div id="smallmenu">
<a href="about.html">About</a> - <a href="sitemap.html">Site Map</a> - <a href="fags.html">Faqs</a>
</div>
<br>

CSS

header {
position:relative;
}
#smallmenu { position:absolute; top:0; right:0; height:20px; <!--If adding more links, make sure #smallmenu width is wide enough--> width:200px; padding:3px 0 0 10px; margin:0; text-align:center; font-size:10pt; color:black; }
#smallmenu a:link { color:black; text-decoration:none; font-weight:bold; outline: none; }
#smallmenu a:visited { color:black; text-decoration:none; font-weight:bold; outline: none; }
#smallmenu a:hover { color:white; text-decoration:none; font-weight:bold; outline: none; }
#smallmenu a:active { color:red; text-decoration:none; font-weight:bold; outline: none; }

The small menu is inside the header element. That makes the header the parent element of the small menu. In CSS positioning, you can position the small menu to appear in the upper right corner of the header. The header is positioned position:relative;. The #smallmenu is positioned position:absolute;. The small menu has to be positioned absolute. In order for the positioning to work, the header element has to be positioned relative. If you dont do that, it won't work.

Previous Home Table of Contents Next