mrwnt10
mrwnt10

Reputation: 1415

What specifically is the CSS reset changing here?

I am new to CSS and was trying to get rid of unwanted whitespace around my body. Following the advice of one of the answers to this question, I included

* {
  margin: 0;
  padding: 0;
}

in my CSS and the whitespace disappeared like I wanted it to. But when I first tried to insert just the following:

html, body {
    margin:0px;
    padding:0px;
}

only the whitespace on the left and right disappeared. The whitespace at the top remained. Why? What is the element that * removes a margin from and causes the top whitespace to disappear?

Upvotes: 1

Views: 41

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201828

Several HTML elements have a top margin by default. It could be an h1 element (the most natural guess I would say), but it could also be ul for example. You really need to look at the HTML code to see what causes the spacing in the particular case.

Upvotes: 1

Musa
Musa

Reputation: 97717

* selects all tags, I'm guessing it was a header causing the space at the top.

Upvotes: 2

Related Questions