What would be the proper way to code the following (with divs and CSS): I want my logo centered on the top of the page (yes, that part is easy) and a Search Box that is positioned all the way to the right (10px from the edge). I don't want the search box to be lower on the page than the logo, so do I float it? (Sorry, kind of a noob question, just want to make sure I'm doing it right.) Thanks
Not sure if I got you right. Is this what you are trying to get: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Untitled</title> <style type="text/css"> #logo { margin-top:10px; margin:0 auto; width:300px; border:1px solid black; } #search { position:absolute; top:10px; right:10px; } </style> </head> <body> <div id="logo"> I am a logo. </div> <div id="search"> <input type="text"><input type="button" value="search"> </div> </body> </html> HTML:
above code replace these lines: margin-top:10px; margin:0 auto; Code (markup): with margin: 10px auto 0 auto; Code (markup): a margin top was set, but then later reset.
I would just create a container DIV the width of your header and contain 2 floating DIVs inside it to hold the logo and search like this: #Top{ width: 800px; height: 100px; } #TopLeft{ width: 400px; height: 100px; float: left; } #TopRight{ width: 400px; height: 100px; float: left; text-align: right: padding-right: 10px; } <div id="Top"> <div id="TopLeft">Your logo \ img will go here</div> <div id="TopRight">Your search will go here</div> </div> Let me know how you get on. EDIT - Just adjust the width's to suit your alignment