Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: not2easy

Message Too Old, No Replies

padding:initial vs. padding:0

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

Junior Member

5+ Year Member Top Contributors Of The Month

joined:Mar 1, 2010
posts: 194
votes: 0


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

<style>
textarea {
padding: 0;
}
</style>
<textarea>Hello, world!</textarea>
9:12 pm on July 17, 2014 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:12700
votes: 244


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.
10:49 pm on July 17, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
posts:904
votes: 5


Yup, no support from IE for 'initial'.
5:59 am on July 18, 2014 (gmt 0)

Junior Member

5+ Year Member Top Contributors Of The Month

joined:Mar 1, 2010
posts: 194
votes: 0


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


This [developer.mozilla.org] can help.
2:13 pm on July 18, 2014 (gmt 0)

Senior Member from US 

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

joined:Oct 17, 2005
posts: 4965
votes: 10


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.).
6:55 pm on July 18, 2014 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:12700
votes: 244


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."
1:37 am on July 19, 2014 (gmt 0)

Junior Member

5+ Year Member Top Contributors Of The Month

joined:Mar 1, 2010
posts: 194
votes: 0


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].
1:45 am on July 19, 2014 (gmt 0)

Senior Member from US 

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

joined:Oct 17, 2005
posts: 4965
votes: 10


That just seems to add confusion.