Hi guys. Why does this sit flush with the top of the page (intended) but then if I put a H1 in it moves down by ~12 pixels? HTML <!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> <link href="css/styles.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="toppanel"> <h1>test</h1> </div> </body> </html> Code (markup): CSS body{border:0px; padding:0px; margin:0px; background-color:#FFFFFF; color:#000000; font:12px/16px arial,verdana,tahoma;} #toppanel{position:relative; width:1000px; background-color:#FFCCCC; margin:0px; padding:0px; border:0px;} Code (markup): Forgive me if I seem confused Thanks in advance.
you may add rules to h1 h1{ font-size : xx-large; } or try not to declare any font size in body tag. it may overriden the #toppanel. instead, declare rules for each tags and elements first. hope this work..
Scorpiono is most likely correct. H1's start out with margins, and margins can collapse to the parent element on some browsers... There's a reason many CSS developers use a "reset" so we don't have to worry about things like that. Simple reset, sucks if you want form elements: * { margin:0; padding:0; } My reset, just hits the elements I am likely to use and not waste time on setting up values I'm just as likely to change: /* null margins and padding to give good cross-browser baseline */ html,body,address,blockquote,div, form,fieldset,caption, h1,h2,h3,h4,h5,h6, hr,ul,li,ol,ul, table,tr,td,th,p,img { margin:0; padding:0; } img,fieldset { border:none; } Code (markup): ... and then there's CSS reloaded, which is fat, bloated and waste time setting a bunch of values your likely to be overriding anyways. http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ The margin-collapse issue you are seeing gets worse if you test across multiple browsers, because I'm willing to bet some (like IE) will show that top margin, while others (Opera/Chrome/Saffy) won't.
Hi .. lonewolff I Agree with Scorpiono and deathshadow. The problems is the h" elements, p, list has default margin and padding. We should set the margin and padding first if we want to reset it.