Style borderPropriété
Objet Style
Définition et utilisation
La propriété border définit ou renvoie trois propriétés de bordure distinctes sous forme abrégée.
Avec cette propriété, vous pouvez définir/renvoyer :
- border-width
- border-style
- border-color
Syntaxe
Définition de la propriété border :
Object.style.border="width style color"
Renvoi de la propriété border :
Object.style.border
Astuce :La propriété border n'a pas de valeur par défaut.
| Parameters | Description |
|---|---|
| width | Définit la largeur de la bordure. |
| style | Définit le style de la bordure. |
| color | Définit la couleur de la bordure. |
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la propriété border.
Exemple
Exemple
Modifier la bordure de l'élément div :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<style type="text/css">
#ex1{
border: thin dotted #FF0000;
}
</style>
<script>
function displayResult(){
document.getElementById("ex1").style.border="thick solid #0000FF";
}
</script>
</head>
<body>
<div id="ex1">Ceci est un texte.</div>
<br>
<button type="button" onclick="displayResult()">Modifier la bordure</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<style type="text/css">
#ex1{
border: thin dotted #FF0000;
}
</style>
<script>
function displayResult(){
document.getElementById("ex1").style.border="thick solid #0000FF";
}
</script>
</head>
<body>
<div id="ex1">Ceci est un texte.</div>
<br>
<button type="button" onclick="displayResult()">Modifier la bordure</button>
</body>
</html>
Essayez-le vous-même »
Objet Style Autres extensions