homepage Welcome to WebmasterWorld Guest from 107.20.25.215
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
padding:initial vs. padding:0
Rain_Lover




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

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

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

 

lucy24




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

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




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

Yup, no support from IE for 'initial'.

Rain_Lover




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

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


This [developer.mozilla.org] can help.

Fotiman




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

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




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

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




msg:4689028
 1:37 am on Jul 19, 2014 (gmt 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].
Fotiman




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

That just seems to add confusion.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved