Border:none and border:0 Use the difference _ Basic tutorial

Source: Internet
Author: User
First, Border:none
Shorthand for Border-style
See the following results in the Chrome review element
Copy Code code as follows:

Element.style {
Border:none;
Border-top-style:none;
Border-right-style:none;
Border-bottom-style:none;
Border-left-style:none;
border-width:initial;
border-color:initial;
}

Using Firebug to view elements in Firefox will see the following results:
Copy Code code as follows:

Element.style {
Border:medium none;
}

Notice this medium value
Second, border:0
Shorthand for Border-width
See the following results in the Chrome review element
Copy Code code as follows:

Element.style {
border:0;
border-top-width:0px;
border-right-width:0px;
border-bottom-width:0px;
border-left-width:0px;
border-style:initial;
border-color:initial;
}

Using Firebug to view elements in Firefox will see the following results:
Copy Code code as follows:

Element.style {
border:0 none;
}

Notice the difference between Border:none and border:0 in Firebug
Let me give you an example to specify
Copy Code code as follows:

<style>
div {border:1px solid black; margin:1em;}
. zerotest div {border:0;}
. nonetest div {border:none;}
div.setwidth {border-width:3px;}
Div.setstyle {border-style:dashed;}
</style>
<div class= "Zerotest" >
<div class= "SetWidth" >
"Border:0" and "border-width:3px"
</div>
<div class= "SetStyle" >
"Border:0" and "border-style:dashed"
</div>
</div>
<div class= "Nonetest" >
<div class= "SetWidth" >
"Border:none" and "border-width:3px"
</div>
<div class= "SetStyle" >
"Border:none" and "border-style:dashed"
</div>
</div>

Interested friends can copy the above code in this browser to try:
Test results:
1. Zerotest. setwidth
Although border-width:3px is defined, Border-style:none does not have a border (IE7 displays a 3-pixel border, which is related to border:0 parsing). The following will be mentioned)
2. Zerotest. SetStyle
Although the definition of border-style:dashed, but border-width:0 So no border
3. Nonetest. SetWidth
Although border-width:3px is defined, Border-style:none does not have a border (IE7 no border)
4. Nonetest. SetStyle
Border-style:dashed Border-style is defined as the default value medium Border-color is black so the dotted box with a 3 pixel color appears (IE7 is one pixel)
Synthesis 1, 4 can be analyzed under the IE7
border:0 is resolved to border-width:0
Border:none is resolved as Border-style:none
Check out the standard browser again.
border:0 More than Border:none rendering a border-width:0, which is why Border:none performance than border:0 high
So designing the hive suggests using border:none to achieve a borderless effect.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.