Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  DHTML, HTML & CSS

border-width Attribute | borderWidth Property


Sets or retrieves the width of the object's left, right, top, and bottom borders.

Syntax

HTML{ border-width: [ "medium" | "thin" | "thick" | length ] {1,4}}
Scriptingobject.style.borderWidth [ = sWidth ]

Possible Values

mediumDefault width.
thinWidth less than the default.
thickWidth greater than the default.
lengthFloating-point number and an absolute units designator (cm, mm, in, pt, pc, or px) or a relative units designator (em or ex).

The property is read/write with a default value of medium; the CSS attribute is not inherited.

Remarks

"{1,4}" in the HTML syntax indicates that up to four different widths may be specified in this order: top, right, bottom, left. If one width is supplied, it is used for all four sides. If two widths are supplied, the first is used for the top and bottom borders, and the second is used for left and right borders. If three widths are supplied, they are used for top, right and left, and bottom borders, respectively.

The SPAN and DIV objects must have either the position or the width property/attribute set in order to apply a border.

The property is supported on block and replaced objects only.

Example

The following examples demonstrate use of both the border-width attribute and the borderWidth property to specify the border's width.

The sample below uses a call to an embedded (global) style sheet to change the border's width to 1 centimeter on a mouse click.

Sample Code

<STYLE>
    TD { border-width:"3mm" }
    .changeborder1 { border-width:"1cm" }
</STYLE>
</HEAD>
<BODY> 
<TABLE BORDER>
<TR>
    <TD onclick="this.className='changeborder1'"
        ondblclick="this.className=''">
        <IMG src="sphere.jpeg"></TD>
</TR>
</TABLE>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

The sample below uses inline script to change the border's width to 1 centimeter on a mouse click.

<TD onclick="this.style.borderWidth='1cm'">

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

See Also

border


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site