Depends on context. But, generally margin-top
is better because you can use :first-child
to remove it. Like so:
div.block {
margin-top: 10px;
}
div.block:first-child {
margin-top: 0;
}
This way, the margins are only in between the blocks.
Only works for more modern browsers, obviously.
Related Contents:
- What’s the difference between align-content and align-items?
- How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags [duplicate]
- How do I center an SVG in a div?
- Fill remaining vertical space with CSS using display:flex
- Scrolling a flexbox with overflowing content
- How to style a div to be a responsive square? [duplicate]
- Truncating long strings with CSS: feasible yet?
- How to make an inline-block element fill the remainder of the line?
- CSS3 box-sizing: margin-box; Why not?
- How to prevent long words from breaking my div?
- Add space between HTML elements only using CSS
- How to get these two divs side-by-side?
- how to make a div to wrap two float divs inside?
- How would YOU do this: Tables or CSS? [closed]
- CSS Flex Box Layout: full-width row and columns
- How to position two divs horizontally within another div
- How to make inactive content inside a div?
- DIV’s vs. Tables or CSS vs. Being Stupid
- Header div stays at top, vertical scrolling div below with scrollbar only attached to that div
- Browser developer tools: what is the Position of the HTML element?
- Stretch horizontal ul to fit width of div
- CSS transform vs position
- Move up character displayed inline
- How to use flex-grow?
- How to remove whitespace that appears after relative positioning an element with CSS
- Twitter bootstrap white gap on right side of page
- See :hover state in Chrome Developer Tools
- CSS3 Transparency + Gradient
- What does it mean when a CSS rule is grayed out in Chrome’s element inspector?
- How do I make a semi transparent background?
- Apply style ONLY on IE
- How to align a div to the top of its parent but keeping its inline-block behaviour?
- Overflow-x:hidden doesn’t prevent content from overflowing in mobile browsers
- Common CSS Media Queries Break Points [duplicate]
- Calculate a percent with SCSS/SASS
- How to style the UL list to a single line
- How to Create Grid/Tile View? [duplicate]
- How to change btn color in Bootstrap
- What is the best CSS Framework and are they worth the effort?
- CSS Properties: Display vs. Visibility
- CSS transition when class removed
- How to use relative/absolute paths in css URLs?
- How can I remove the bold from a headline?
- How do I hide anchor text without hiding the anchor?
- How do I include a font awesome icon in my svg?
- How can I align text center on small screens with Bootstrap?
- CSS-Only Sticky Table Headers In Chrome
- How can I transition height: 0; to height: auto; using CSS?
- Angular2 Material Dialog css, dialog size
- Is there a way to use wildcards in css id tag