Javascript DOM CSS Style borderRight Property

Introduction

Add a right border to a <div> element:

document.getElementById("myDiv").style.borderRight = "thick solid #0000FF";

View in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Set right border</button>

<script>
function myFunction() {//from   w w  w . ja  v a  2 s  .c o  m
  document.getElementById("myDiv").style.borderRight = "thick solid #0000FF";
}
</script>

</body>
</html>

The borderRight property sets or gets up to three separate border-right properties, in a shorthand form.

With this property, you can set/get one or more of the following:

  • border-right-width
  • border-right-style
  • border-right-color

Property Values

Parameter Description
width the width of the right border
style the style of the right border
color the color of the right border
initial to its default value.
inherit Inherits this property from its parent element.

The borderRight property returns a String representing the width, style and/or color of the right border of an element.




PreviousNext

Related