- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the color of the outline around an element with JavaScript?
To set the outline color, use the outlineColor property. You can try to run the following code to set the color of the outline around an element with JavaScript:
Example
<!DOCTYPE html> <html> <head> <style> #box { width: 450px; background-color: orange; border: 3px solid red; } </style> </head> <body> <p>Click below to add Outline Color.</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 Color</button> <br> <script> function display() { document.getElementById("box").style.outline = "thick solid"; document.getElementById("box").style.outlineColor = "#5F5F5F"; } </script> </body> </html>
- Related Articles
- How to set the width of the outline around an element with JavaScript?
- How to set the style of the outline around an element with JavaScript?
- How to set outline color with JavaScript?
- Set the color of the outline with CSS
- How to set the color of an elements border with JavaScript?
- Set the background color of an element with CSS
- 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 return the background color of an element with JavaScript DOM?
- 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?
- How to set the right padding of an element with JavaScript?

Advertisements