Change the width, style and color of the outline of a <div> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:outline

Description

Change the width, style and color of the outline of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//  w ww. ja va  2  s.  c o  m
    border: 3px solid red;
    outline: 3px solid blue;
}
</style>
</head>
<body>

<div id="myDiv">This is a div.</div>
<br>
<button type="button" onclick="myFunction()">Change outline</button>

<script>
function myFunction() {
    document.getElementById("myDiv").style.outline = "5px dotted green";
}
</script>

</body>
</html>

Related Tutorials