CSS: Remove body margins
P粉403804844
P粉403804844 2023-10-14 19:48:32

I'm new to web development and I'm having trouble removing body text margins.

There is space between the very top of the browser and the "logo" text. My code is on jsbin.

If I want to remove spaces, body { margin: 0;} Is it wrong?

P粉403804844
P粉403804844

reply all(2)
P粉038856725

Certain HTML elements have predefined margins (ie: body, h1 to h6, p, >fieldsetformuloldldir >、menu, blockquote and dd).

In your case, it is h1 that is causing your problem. By default it has { margin: .67em } . If you set it to 0, it will remove spaces.

To solve such problems, I recommend using the browser's development tools. For most browsers: Right-click the element you want to learn more about and select "Inspect Element." At the very bottom of the Styles tab, you have a CSS box model. This is a great tool for visualizing borders, padding, and margins and which elements are the source of your styling issues.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!