It is currently Sat Dec 14, 2024 11:09 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to remove margin space around body or clear default css
PostPosted: Wed Jul 20, 2022 11:55 am 
Newbie
Newbie

Joined: Sat Jun 18, 2022 6:12 am
Posts: 4
I am admittedly a beginner, but I also did a fair amount of searching before posting this. There seems to be extra space around my div element. I also would like to point out that I tried many combinations of border: 0, padding:0, etc. and nothing seemed to get rid of the white space.


Top
 Profile  
 
 Post subject: Re: How to remove margin space around body or clear default
PostPosted: Thu Jul 21, 2022 4:38 pm 
Site Admin

Joined: Sat May 31, 2008 1:56 am
Posts: 500
Please note that this is a forum for our hosting and in general we do not offer web development services or have the knowledge to answer most of the questions on this matter. You might find more information in web developers' forums instead. Thank you for your understanding.

_________________
Best Regards,
Miles
ModeratorsTeam
Freehostia.com


Top
 Profile  
 
 Post subject: Re: How to remove margin space around body or clear default
PostPosted: Thu Aug 04, 2022 7:17 am 
Newbie
Newbie

Joined: Wed Jul 13, 2022 11:40 am
Posts: 2
I've been using css and scss with and without frameworks and libs for quite a while now, and the more I think about it, the less I want to use the margin property.

Here are my reasons :

most of its uses overlap with padding's uses

it is less visually readable than the padding property

it's not counted in an element's size (width or height)

it has a hard to predict behavior because or collapsing margins

it can be negative (becomes even less readable)

most of its specific uses (margin auto to center a block element, spacing after a border, spacing for and element with background...) can be replicated in a cleaner way using flexbox and gap.

I'm thinking of completely ignoring this property from now on (exactly like I did for float, for example), what do you guys think about this ? Do you see any obvious mistake ?


Top
 Profile  
 
 Post subject: Re: How to remove margin space around body or clear default
PostPosted: Fri Sep 16, 2022 7:47 am 
Newbie
Newbie

Joined: Fri Jul 22, 2022 11:47 am
Posts: 3
body has by default 8px margins: http://www.w3.org/TR/CSS2/sample.html

body {
margin: 0; /* Remove body margins */
}
Or you could use this useful Global reset

*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
If you want something less * global:

html, body, body div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, hgroup, menu, nav, section, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011