The `border` Confusion
Published on
Occasionally, confusion around border: 0 vs border: none comes up in code reviews.
Let’s try to clarify this a bit:
The border property is a shorthand that allows us to set multiple values at once. For example, these declarations are equivalent:
/* Shorthand */
border: 1px solid #000;
/* Longhand */
border-width: 1px;
border-style: solid;
border-color: #000;So, border: 0 is equivalent to border-width: 0, while border: none is equivalent to border-style: none. Since a border without width or style can’t be rendered, both values achieve the same result.
If the goal is to remove a border, I find border: 0 more explicit. Ultimately, as long as we stay consistent, either approach works just fine.