is -negative margin or padding are invalid CSS aaccording to W3C ?
In general, use margins when you're adjusting the spacing of an element in relation to another element (i.e a div in relation to another div on the page), and padding when you're adjusting the look of an individual element (i.e the amount of pixels between the edge of a div and the text within it).
margin: 10px 5px 15px 20px; top margin is 10px. right margin is 5px. bottom margin is 15px. left margin is 20px.
One of the key differences between margin and padding is the way they create space around elements. A margin pushes the elements that surround your text or image farther away. Padding expands to create more space around an element or reduces the size of the content within its borders.
The margin clears an area around an element (outside the border), but the padding clears an area around the content (inside the border) of an element. it means that your element does not know about its outside margins, so if you are developing dynamic web controls, I recommend that to use padding vs margin if you can.
According to Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification - 8.4 Padding properties, negative margin values are valid, negative padding values are not:
Unlike margin properties, values for padding values cannot be negative
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With