Latest web development tutorials

HTML DOM Style borderWidth property

Style Object Reference Style Objects

Definition and Usage

borderWidth property sets or returns the width of the element's border.

This property can be used 1-4 kinds Width:

  • If you specify a width, for example: p {border-width: thick} - all four borders are thick line.
  • If you specify two widths, for example: p {border-width: thick thin} - upper and bottom borders are thick line and the left border and right border is thin.
  • The provisions in three widths, for example: p {border-width: thick thin medium} - is a thick line on the border, left border and right border is thin, the border is under moderate line.
  • The provisions in four widths, for example: p {border-width: thick thin medium 10px} - is on the border of thick and thin is the right border, the bottom border of the middle line, the width of the left border of 10px.

grammar

Setting borderWidth properties:

Object.style.borderWidth="thin|medium|thick|length|inherit"

Back borderWidth properties:

Object.style.borderWidth

描述
thin 定义细的边框。
medium 默认。定义中等的边框。
thick 定义粗的边框。
length 允许您自定义边框的宽度。
inherit 边框的宽度是从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support borderWidth property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Change the width of the four borders:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Style type = "text / css">
# Ex1 {
border: 1px solid # FF0000;
}
</ Style>
<Script>
function displayResult () {
. Document.getElementById ( "ex1") style.borderWidth = "thick thin";
}
</ Script>
</ Head>
<Body>

<Div id = "ex1"> This is some text </ div>
<br>
<Button type = "button" onclick = "displayResult ()"> Modify the width of the four borders </ button>

</ Body>
</ Html>

try it"


Style Object Reference Style Objects