Which of the two methods conforms to W3C standards? Do they both behave as expected across browsers?
border: none;
border: 0;
Like the none keyword, displays no border. Unless a background-image is set, the computed value of the same side's border-width will be 0 , even if the specified value is something else.
We can specify the no border property using CSS border: none, border-width : 0, border : 0 properties. Approach 1: We will give border-color, border-style properties to both headings, for showing text with border and no-border. For no border heading, we will use the border-width : 0 which will result in no border.
Both are valid. It's your choice.
I prefer border:0
because it's shorter; I find that easier to read. You may find none
more legible. We live in a world of very capable CSS post-processors so I'd recommend you use whatever you prefer and then run it through a "compressor". There's no holy war worth fighting here but Webpack→LESS→PostCSS→PurgeCSS is a good 2020 stack.
That all said, if you're hand-writing all your production CSS, I maintain —despite the grumbling in the comments— it does not hurt to be bandwidth conscious. Using border:0
will save an infinitesimal amount of bandwidth on its own, but if you make every byte count, you will make your website faster.
The CSS2 specs are here. These are extended in CSS3 but not in any way relevant to this.
'border' Value: [ <border-width> || <border-style> || <'border-top-color'> ] | inherit Initial: see individual properties Applies to: all elements Inherited: no Percentages: N/A Media: visual Computed value: see individual properties
You can use any combination of width, style and colour.
Here, 0
sets the width, none
the style. They have the same rendering result: nothing is shown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With