Atributo Style borderColor
- Página anterior borderCollapse
- Página siguiente borderImage
- Volver a la capa superior Objeto Style de HTML DOM
Definición y uso
borderColor
La propiedad establece o devuelve el color del borde del elemento.
Esta propiedad puede usar de uno a cuatro valores:
- Un valor, por ejemplo: p {border-color: red} - todos los cuatro bordes son rojos
- Two values, for example: p {border-color: red transparent} - The top and bottom borders are red, and the left and right borders are transparent
- Three values, for example: p {border-color: red green blue}- The top border is red, the left and right borders are green, and the bottom border is blue
- Four values, for example: p {border-color: red green blue yellow} - The top border is red, the right border is green, the bottom border is blue, and the left border is yellow
See also:
CSS Tutorial:Borde de CSS
CSS Reference Manual:border-color property
HTML DOM Reference Manual:border property
Example
Example 1
Change the color of all four borders of the <div> element to red:
document.getElementById("myDiv").style.borderColor = "red";
Example 2
Change the color of the top and bottom borders of the <div> element to green, and the color of the left and right borders to purple:
document.getElementById("myDiv").style.borderColor = "green purple";
Example 3
Return the border color of the <div> element:
alert(document.getElementById("myDiv").style.borderColor);
Syntax
Return borderColor property:
object.style.borderColor
Set borderColor property:
object.style.borderColor = "color|transparent|initial|inherit"
Property value
Value | Description |
---|---|
color |
Specifies the border color. The default color is black. See CSS color values, for a complete list of possible color values. |
transparent | The border color is transparent (the underlying content will show through). |
initial | Set this property to its default value. See initial. |
inherit | Inherit this property from its parent element. See inherit. |
Technical details
Default value: | black |
---|---|
Return value: | A string representing the color of the element's border. |
CSS version: | CSS1 |
Browser support
The numbers in the table indicate the first browser version to fully support this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
- Página anterior borderCollapse
- Página siguiente borderImage
- Volver a la capa superior Objeto Style de HTML DOM