Welcome to WebmasterWorld Guest from 50.19.53.104

Forum Moderators: not2easy

Message Too Old, No Replies

padding:initial vs. padding:0

     

Rain_Lover

8:27 pm on Jul 17, 2014 (gmt 0)

5+ Year Member Top Contributors Of The Month



Does
padding:initial
have any advantage over
padding:0
? Example:

<style>
textarea {
padding: 0;
}
</style>
<textarea>Hello, world!</textarea>

lucy24

9:12 pm on Jul 17, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



padding:initial

I would worry about backward compatibility, since I can't even find this form in the CSS docs :( What browsers support it?

padding: 0
seems safer, and is unambiguous. I include it in my boilerplate for some elements.

rainborick

10:49 pm on Jul 17, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yup, no support from IE for 'initial'.

Rain_Lover

5:59 am on Jul 18, 2014 (gmt 0)

5+ Year Member Top Contributors Of The Month



I can't even find this form in the CSS docs :( What browsers support it?


This [developer.mozilla.org] can help.

Fotiman

2:13 pm on Jul 18, 2014 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Note, it appears that "initial" is not supported at all in IE, so that would be one reason not to use it.
Also, comparing padding:initial to padding:0 is not always accurate. Some elements my have some default padding (like ul and ol, etc.).

lucy24

6:55 pm on Jul 18, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Can't help noting that the first thing they say is
On inherited properties, the initial value may be surprising and you should consider using the inherit or unset keywords instead.

The word "surprising" is good. I would treat it as equivalent to Apache "unexpected" or "unintended", which tends to mean "We cannot guarantee that the world as you know it will NOT end."

Rain_Lover

1:37 am on Jul 19, 2014 (gmt 0)

5+ Year Member Top Contributors Of The Month



Some elements my have some default padding (like ul and ol, etc.).


The "initial value" and "browser default value" are not the same: the initial value is defined by spec, which is separate from what value the browser assigns to certain properties on certain elements as part of its default stylesheet. In my example, the browser default value is
0px
in Firefox and
2px
in Chrome, while the initial value is
0px
according to the spec [w3.org].

Fotiman

1:45 am on Jul 19, 2014 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



That just seems to add confusion.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month