I made a website that looks perfect on Internet Explorer, but when it is loaded with Firefox, certain elements are out of alignment.
For example, a p tag that would appear on the coordinates 20, 20, would appear in firefox on the coordinates 20, 40. For some reason, firefox changes the ‘top’ attribute of my p tags, such that they appear “lower” in firefox, than in ie. Please note that the ‘left’ attribute’ remains unhindered, but the value for the ‘top’ (or y coordinate) is increased by about 20 pixels, everytime!
I would like to know why my P tags appear in their proper locations in Internet Explorer, but are lower in firefox?
Below is the code I used for each p tag. If you were to use this same code in a web page, you would see clearly that the p tag appears lower in firefox, than in i.e. everytime.
p.myparagraph
{position: absolute;
left: 20px;
top: 170px;
width: 20px;
height: 19px;
background-color:0033dd;
}
Why are my p tags appearing 30 pixels lower in firefox, than in Internet Explorer?
Each browser has its own CSS applied by default. To counter this, it is good practice to use some sort of CSS normalization (as pointed out by @You) before applying custom CSS. CSS normalization is recommended over an outright reset because it
Source: Normalize.css
Also, do check out Initializr. It offers that plus a lot more, including IE6+ compatibility/fallbacks etc.
If not that, you could use a basic CSS reset,
Source: http://meyerweb.com/eric/tools/css/reset/