Propriété borderWidth du style
- Page précédente borderTopWidth
- Page suivante bottom
- Retour au niveau supérieur Objet Style HTML DOM
Définition et utilisation
borderWidth
Cette propriété configure ou retourne la largeur de la bordure de l'élément.
Cette propriété peut accepter une à quatre valeurs :
- Une valeur, par exemple : p {border-width: épais} - Tous les quatre bords sont épais
- Two values, for example: p {border-width: thick thin} - Top and bottom borders thick, left and right borders thin
- Three values, for example: p {border-width: thick thin medium} - Top border thick, left and right borders thin, bottom border medium
- Four values, for example: p {border-width: thick thin medium 10px} - Top border thick, right border thin, bottom border medium, left border 10px
See also :
CSS Tutorial :Bordure CSS
CSS Reference Manual :border-width property
HTML DOM Reference Manual :border property
Instance
Example 1
Change the width of the four borders of the <div> element :
document.getElementById("myDiv").style.borderWidth = "thick";
Example 2
Change the width of the top and bottom borders of the <div> element to thick and the width of the left and right borders to thin :
document.getElementById("myDiv").style.borderWidth = "thick thin";
Example 3
Use length values to change the width of the four borders of the <div> element :
document.getElementById("myDiv").style.borderWidth = "1px 5px 10px 20px";
Example 4
Return the border width of the <div> element :
alert(document.getElementById("myDiv").style.borderWidth);
Syntax
Return borderWidth property :
object.style.borderWidth
Set borderWidth property :
object.style.borderWidth = "thin|medium|thick|length|initial|inherit"
Value | Description |
---|---|
thin | Define thin border. |
medium | Define medium border. Default. |
thick | Define thick border. |
length | Border width measured in length. |
initial | Set this property to its default value. See initial. |
inherit | Inherit this property from its parent element. See inherit. |
Technical details
Default value : | medium |
---|---|
Return value : | A string representing the width of the element's border. |
CSS version : | CSS1 |
Compatibilité du navigateur
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Page précédente borderTopWidth
- Page suivante bottom
- Retour au niveau supérieur Objet Style HTML DOM