Style borderPropiedad
Objeto Style
Definición y uso
La propiedad border establece o devuelve las tres propiedades de borde independientes en forma abreviada.
Con esta propiedad, puede establecer/devolver:
- border-width
- border-style
- border-color
Sintaxis
Establecer la propiedad border:
Object.style.border="width style color"
Devolver la propiedad border:
Object.style.border
Sugerencia:La propiedad border no tiene un valor predeterminado.
| Parámetros | Descripción |
|---|---|
| width | Establece el ancho del borde. |
| style | Establece el estilo del borde. |
| color | Establece el color del borde. |
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad border.
Ejemplo
Ejemplo
Cambiar el borde de un elemento div:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ejemplo(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">Este es un texto.</div>
<br>
<button type="button" onclick="displayResult()">Cambiar borde</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Ejemplo(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">Este es un texto.</div>
<br>
<button type="button" onclick="displayResult()">Cambiar borde</button>
</body>
</html>
Pruébalo »
Objeto Style Otras extensiones