HTML DOM border 属性

HTML DOM Style 对象参考手册

定义和用法

border 属性在一个声明中设置所有边框属性。

语法:

Object.style.border=borderWidth borderStyle borderColor
描述
borderWidth 设置边框的宽度。
  • thin
  • medium
  • thick
  • length
borderStyle 设置边框的样式。
  • none
  • hidden
  • dotted
  • dashed
  • solid
  • double
  • groove
  • ridge
  • inset
  • outset
borderColor 设置边框的颜色。
  • color-name
  • color-rgb
  • color-hex
  • transparent

实例

本例改变元素的边框:

<html>
<head>
<style type="text/css">
p
{ 
border: thin dotted #FF0000
}
</style>
<script type="text/javascript">
function changeBorder()
{
document.getElementById("p1").style.border="thick solid #0000FF";
}
</script>
</head>
<body>

<input type="button" onclick="changeBorder()"
value="Change border" />

<p id="p1">This is a paragraph</p>

</body>
</html>

HTML DOM Style 对象参考手册