tags:

views:

47

answers:

3

I've just noticed myself using both border: none and border: 0 to reset a border in the cascade.

Is there a One True Way™ to reset a border that has already been set?

+1  A: 

Sounds pretty subjective if you ask me :) Personally I use border: none as it semantically makes more sense. I use the number 0 if I'm only setting border-width.

EDIT: as you should probably be aware, border is a shorthand property. I found out that both of those values do not pertain to the shorthand property itself but each belongs to one of the more 'fine-grained' CSS border properties.

  • none is a value for border-style
  • 0 is a value for border-width

Either way, you're really just defining no border.

BoltClock
Well I was wondering if any which one was the right way... thought I may as well be doing it right instead of relying on a browser quirk (if any).
alex
+1  A: 

Completely up to you, some say one way, some say the other. The border: none is the 'technical' way to do it because 'none' is a listed allowed value for border, but border: 0 is just basically a short-hand version to save a few extra characters. I don't even know which one I use, it doesn't really bother me either way.

Edit: Here's another good conversation on a similar topic (0 vs 0em)...
http://stackoverflow.com/questions/935107/css-difference-between-0-and-0em

animuson
A: 

technically, it should be border: 0 <-- if you are using the short hand,

OR border-style:none; <-- I prefer this, but if a few char matters...


The shorthand is border: [width] [style] [color];

http://www.w3schools.com/css/css_border.asp (or the formal specification: http://www.w3.org/TR/CSS2/box.html#border-properties)

Note: As pointed out by below comment. border: 0px; is redundant but border: 1px; is not. Units (em, ex, px, etc) are not optional when value > 0.

Kasumi
"technically, it should be border: 0px" No - the px unit is redundant.
e100
you are correct, I will make an edit, units are optional for 0's.
Kasumi