
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to set the width of the outline around an element with JavaScript?
To set the outline width, use the outlineWidth property. You can try to run the following code to set the width of the outline around an element with JavaScript −
Example
<!DOCTYPE html> <html> <head> <style> #box { width: 450px; background-color: orange; border: 3px solid red; margin-left: 20px; } </style> </head> <body> <p>Click below to add Outline Width.</p> <div id="box"> <p>This is a div. This is a div. This is a div. This is a div. This is a div.</p> <p>This is a div. This is a div. This is a div. This is a div. This is a div.</p> <p>This is a div. This is a div. This is a div. This is a div. This is a div.</p> </div> <br> <button type="button" onclick="display()">Set Outline Width</button> <br> <script> function display() { document.getElementById("box").style.outlineColor = "#5F5F5F"; document.getElementById("box").style.outlineStyle = "solid"; document.getElementById("box").style.outlineWidth = "7px"; } </script> </body> </html>
- Related Articles
- How to set the color of the outline around an element with JavaScript?
- How to set the style of the outline around an element with JavaScript?
- How to set the maximum width of an element with JavaScript?
- How to set the minimum width of an element with JavaScript?
- How to set the width of an element in JavaScript?
- Set the width of the outline with CSS
- How to set the width of an element's border with JavaScript?
- How to set outline color with JavaScript?
- How to set the padding of an element with JavaScript?
- How to set the height of an element with JavaScript?
- How to set the margins of an element with JavaScript?
- How to set the top position of an element with JavaScript?
- How to set the bottom padding of an element with JavaScript?
- How to set the left padding of an element with JavaScript?
- How to set the top padding of an element with JavaScript?

Advertisements