Highlight drawn incorrectly when body margins are 0
See original GitHub issueI created a little landmarks test page, which I want to completely fill the browser’s height and width without scrolling.
When I set CSS margin for body
to 0;
- the highlight border box is drawn a bit too small on the right (except for the nav)
- the nav’s highlight title is drawn too far to the right (the other highlight titles are drawn in the correct place)
To see the difference between correct highlighting and incorrect highlighting, first run the example and use <kbd>Alt + Shift + N</kbd> (Windows) to move through the landmarks. Note that the highlights are drawn a little bit off:
Now open DevTools (I’m using Chrome, but saw this in Firefox as well) and uncheck the body
style for margin: 0;
. The body inherits an 8px margin from the browser’s style sheet, which causes an annoying vertical scrollbar, but the highlights are ok:
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
CSS Margin: 0 is not setting to 0 - Stack Overflow
I'm a new comer to web designing. I created my web page layout using CSS and HTML as below. The problem is even...
Read more >margin - CSS: Cascading Style Sheets - MDN Web Docs
The margin CSS shorthand property sets the margin area on all four sides of an element.
Read more >Align text or adjust the margins within a text box
Click the outer edge of the text box to select it. · On the Shape Format tab, click Format Pane. · Click the...
Read more >Can you help me solve this problem? : r/css - Reddit
margin : 0.5em auto; display: block; height: auto; ... @media screen { body { margin: 0; padding: 0; -webkit-user-select: none; overflow-x: ...
Read more >8 Box model - W3C
If the margin has 0 width, the margin edge is the same as the border edge. ... body { margin: 2em } /*...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the helpful debugging @carmacleod. I’ll look into it soon. (As it happens, I hadn’t recieved notification of this when you reported it, sorry for the laggy reply.)
Here we go…