How to Remove Default Browser Styling With a Master Stylesheet

Get the Facts With These Tips

Graphic of an outline of an application window on an iMac
ilyast / Getty Images

All web browsers include what is known as "default styles." These are styles that dictate the look and feel of HTML elements in the absence of any other style information. For example, in nearly every browser the default look of hyperlinks is a bright blue color with an underline. This is how those links look unless you tell them to display in a different way. 

Default browser styles can be helpful, but in many cases, web designers want to remove these styles so that they can start fresh with styles that they are 100% in control of. This is done using what is known as a "master stylesheet."

A master stylesheet should be the first stylesheet you call in all your documents. You use a master stylesheet to clear out the default browser settings that can cause problems in cross-browser Web design. Once you've cleared out the styles with a master stylesheet, your design starts from the same place in all the browsers - like a clean canvas for painting.

Global Defaults

Your master stylesheet should start by zeroing out the margins, paddings, and borders on the page. Some web browsers default the body of the document to 1 or 2 pixels indented from the browser pane edges. This makes sure that they all display the same.

You also want to make the font consistent. Be sure to also set the font size to 100 percent or 1em, so that your page is accessible, but the size is still consistent. And be sure to include the line-height.

Headline Formatting

Headline or header tags (H1, H2, H3, etc.) typically default to bold text with large margins or padding around them. By clearing the weight, margins, and padding, you ensure that these tags still remain larger (or smaller) than the text around them without having extra styles.

You might want to consider setting specific sizes, letter-spacing, and paddings to your headline tags, but that really depends on the style of the site you're designing and should be left out of the master style sheet. You can add more styles to these headings as needed for your specific design.

Plain Text Formatting

Beyond headlines, there are other text tags that you should be sure to clear out. One set that people often forget are the table cell tags (TH and TD) and form tags (SELECT, TEXTAREA, and INPUT). If you don't set those to the same size as your body and paragraph text, you may be unpleasantly surprised at how the browsers render them.

It's also nice to give your quotations (BLOCKQUOTE and Q), acronyms, and abbreviations a little extra style so that they stand out a little more:

Links and Images

Links are easy to manage and to change from that aforementioned bright blue underlined text. We prefer to always have our links remain underlined, but if you prefer it a different way you can set these options separately. We also don't include colors in the master style sheet, because that depends upon the design.

With images, it's important to turn off the borders. While most browsers don't display a border around a plain image, when the image is linked, the browsers turn on the border.


While tables are no longer used for layout purposes, your site may still use them for actual tabular data. This is a fine use of HTML tables. We've already made sure that the default text size is the same for your table cells, but there are a few other styles you should set so that your tables stay the same:


Like with other elements, you should clear out the margins and paddings around your forms. Another thing we like to do is rewrite the form tag as "inline" so that it doesn't add extra space where you place the tag in the code. As with other text elements, we define the font information for select, textarea and input up above, so that it's the same as the rest of our text.

It's also a good idea to change the cursor for your labels. This helps people to see that the label will do something when they click it.

Common Classes

For this part of the master stylesheet, you should define classes that make sense to you. These are some of the classes we use most often. Note that they are not set to any particular element, so you can assign them to whatever you need.

Remember that because these classes are written before any other styles and they are just classes, they are easy to override with more specific style properties that occur later in the cascade. If you find that you set a common class on an element and it doesn't take effect, you should check to make sure that there is not some other style in one of your later stylesheets affecting that same element.