26 lines
701 B
Markdown
26 lines
701 B
Markdown
---
|
|
title: Add a Negative Margin to an Element
|
|
---
|
|
## Add a Negative Margin to an Element
|
|
|
|
Margin is the spacing between the border of an element and other elements on the page.
|
|
|
|
•There is spacing from the top, right, bottom, and left.
|
|
|
|
•The number is in [css units](https://www.tutorialspoint.com/css/css_measurement_units.htm)
|
|
|
|
For example, to adjust the margin of an element to be negative you could use:
|
|
|
|
```css
|
|
.example {
|
|
margin: -10px;
|
|
}
|
|
```
|
|
|
|
<b>To adjust the padding of an individual element</b> use:
|
|
padding: `-10`px;
|
|
|
|
[You can find out much more about negative margins here](https://www.smashingmagazine.com/2009/07/the-definitive-guide-to-using-negative-margins/)
|
|
|
|
Good luck!
|