Browser user agent style sheet margin 8px

不羁岁月 提交于 2019-12-21 07:56:32

问题


I was just wonerdering about a white space all around a website. I found out it is there because of the user agent style sheet (Google Chrome) and there is set a margin of 8px to the body tag as default.

How to solve this is not a problem, but I am interested in the reason of this margin. I searched for it, but I only find solutions to set the margin zero, but I want to know why this margin is there.

Hope you can tell me more about these user agent stylesheets.

Greetings Philipp


回答1:


Browsers add their own stylesheet with their proper rules to show how the web page should be rendered normally good looking for eg. some reason you'd not add css rules for headers then how it should be displayed in the browsers?

To answer the question browsers add their rules to show the web page headers how would normally look like.

Like that the browsers using margin:8px; in body to show a web page in a cleaner visual way as pointed out by @Quentin is as writing in a paper.

So, we are the developer and how should be the page rendered?

To answer this we add our own stylesheet and make our own way for visual effect on the page.


There are a lot of rules in the stylesheet added by browsers in default by different browsers. You can see them here for different browsers.

And you may find several css reset stylesheet googling.




回答2:


It is there because text that touches the border of the window is hard to read. i.e. for the same reason that we use margins when writing on paper.



来源:https://stackoverflow.com/questions/32624315/browser-user-agent-style-sheet-margin-8px

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!