Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is -negative margin or padding invalid CSS according to W3C?

is -negative margin or padding are invalid CSS aaccording to W3C ?

like image 905
Jitendra Vyas Avatar asked Oct 26 '09 05:10

Jitendra Vyas


People also ask

Should I use margin or padding CSS?

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).

What does margin 10px 5px 15px 20px mean?

margin: 10px 5px 15px 20px; top margin is 10px. right margin is 5px. bottom margin is 15px. left margin is 20px.

What is margin and padding in web design?

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.

Is margin better than padding?

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.


1 Answers

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

like image 59
Andrew Hare Avatar answered Oct 18 '22 15:10

Andrew Hare