Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
HTML | DOM Style outlineWidth Property
Next article icon

HTML | DOM Style outlineWidth Property

Last Updated : 08 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The DOM Style outlineWidth property is used to set or return the width of the outline around an element. The outline is the line that is created around the specified element outside the border of the element to make the particular distinct and easier to distinguish.

Syntax:

  • It returns the outlineWidth property.
object.style.outlineWidth
  • It is used to set the outlineWidth property.
object.style.outlineWidth = "thin|medium|thick|length|initial| inherit"

Return Values: It returns a string value, that represents the width of an element's outline.

Property Values:

1. thin: It sets the outline width to thin, the outline achieved is thinner than outline specified with width as medium and thick.

Example: 

HTML
<!DOCTYPE html> <html> <head>     <title>         DOM Style outlineWidth Property     </title>     <style>         .elem {             outline-style: dashed;         }     </style> </head>  <body>     <h1 style="color: green">         GeeksforGeeks     </h1>     <b>DOM Style OutlineWidth</b>     <p class="elem">         GeeksforGeeks is a computer science portal         with a huge variety of well written and          explained computer science and programming         articles, quizzes and interview questions.         The portal also has dedicated GATE preparation         and competitive programming sections.     </p>     <button onclick="changeWidth()">         Change outlineWidth     </button>     <!--Script to change the outline width -->     <script>         function changeWidth() {             elem = document.querySelector('.elem');             elem.style.outlineWidth = 'thin';         }     </script> </body> </html>                     

Output:

  • Before clicking the button:

 thin_before

  • After clicking the button:

 thin_after

2. medium: It sets the outline width to default. The width of the outline is thinner than the outline sets thick and thicker than the outline set as thin. 

Example: 

HTML
<!DOCTYPE html> <html>   <head>     <title>         DOM Style outlineWidth Property     </title>      <style>         .elem {             outline-style: dashed;             outline-width: thin;         }     </style> </head>  <body>     <h1 style="color: green">         GeeksforGeeks     </h1>     <b>DOM Style OutlineWidth</b>     <p class="elem">         GeeksforGeeks is a computer science portal         with a huge variety of well written and          explained computer science and programming         articles, quizzes and interview questions.         The portal also has dedicated GATE preparation         and competitive programming sections.     </p>     <button onclick="changeWidth()">         Change outlineWidth     </button>     <!--Script to change the outline width -->     <script>         function changeWidth() {             elem = document.querySelector('.elem');             elem.style.outlineWidth = 'medium';         }     </script> </body> </html>                     

Output:

  • Before clicking the button:

 medium-before

  • After clicking the button:

 medium-after

3. thick: It sets the outline width to thick, the outline achieved is thicker than outline specified with width as medium and think.

Example: 

HTML
<!DOCTYPE html> <html> <head>     <title>         DOM Style outlineWidth Property     </title>     <style>         .elem {             outline-style: dashed;         }     </style> </head> <body>     <h1 style="color: green">         GeeksforGeeks     </h1>     <b>DOM Style OutlineWidth</b>     <p class="elem">         GeeksforGeeks is a computer science portal         with a huge variety of well written and          explained computer science and programming         articles, quizzes and interview questions.         The portal also has dedicated GATE preparation         and competitive programming sections.     </p>     <button onclick="changeWidth()">         Change outlineWidth     </button>     <!--Script to change the outline width -->     <script>         function changeWidth() {             elem = document.querySelector('.elem');             elem.style.outlineWidth = 'thick';         }     </script> </body> </html>                     

Output:

  • Before clicking the button:

 thick-before

  • After clicking the button:

 thick-after

4. length: It is used to define the outline width in terms of length units. 

Example: 

HTML
<!DOCTYPE html> <html> <head>     <title>         DOM Style outlineWidth Property     </title>     <style>         .elem {             outline-style: dashed;         }     </style> </head> <body>     <h1 style="color: green">         GeeksforGeeks     </h1>     <b>DOM Style OutlineWidth</b>     <p class="elem">         GeeksforGeeks is a computer science portal         with a huge variety of well written and          explained computer science and programming         articles, quizzes and interview questions.         The portal also has dedicated GATE preparation         and competitive programming sections.     </p>     <button onclick="changeWidth()">         Change outlineWidth     </button>     <!--Script to change the outline width -->     <script>         function changeWidth() {             elem = document.querySelector('.elem');             elem.style.outlineWidth = '10px';         }     </script> </body> </html>                     

Output:

  • Before clicking the button:

 length-before

  • After clicking the button:

 length-after

5. initial: It is used to set this property to its default value. 

Example: 

HTML
<!DOCTYPE html> <html> <head>     <title>         DOM Style outlineWidth Property     </title>     <style>         .elem {             outline-style: dashed;             outline-width: 4px;         }     </style> </head> <body>     <h1 style="color: green">         GeeksforGeeks     </h1>     <b>DOM Style OutlineWidth</b>     <p class="elem">         GeeksforGeeks is a computer science portal         with a huge variety of well written and          explained computer science and programming         articles, quizzes and interview questions.         The portal also has dedicated GATE preparation         and competitive programming sections.     </p>     <button onclick="changeWidth()">         Change outlineWidth     </button>     <!--Script to change the outline width -->     <script>         function changeWidth() {             elem = document.querySelector('.elem');             elem.style.outlineWidth = 'initial';         }     </script> </body> </html>                     

Output:

  • Before clicking the button:

 initial-after

  • After clicking the button:

 initial-after

6. inherit: This inherits the property from its parent. 

Example: 

HTML
<!DOCTYPE html> <html> <head>     <title>         DOM Style outlineWidth property     </title>     <style>         #parent {             padding: 10px;             outline-style: dashed;              /* Set the outlineWidth of             parent element */             outline-width: 5px;         }         .elem {             outline-style: dotted;         }     </style> </head> <body>     <h1 style="color: green">         GeeksforGeeks     </h1>     <b>DOM Style OutlineWidth</b>     <br><br>     <div id="parent">         <p class="elem">             GeeksforGeeks is a computer science portal             with a huge variety of well written and              explained computer science and programming             articles, quizzes and interview questions.             The portal also has dedicated GATE preparation             and competitive programming sections.         </p>     </div>     <br>     <button onclick="changeWidth()">         Change outlineWidth     </button>     <!-- Script to change the outline width -->     <script>         function changeWidth() {             elem = document.querySelector('.elem');             elem.style.outlineWidth = 'inherit';         }     </script> </body> </html>                     

Output:

  • Before clicking the button:

 inherit-before

  • After clicking the button:

 inherit-after

Supported Browsers: The browser supported by DOM Style outlineWidth property are listed below:

  • Google Chrome 1
  • Edge 12
  • Internet Explorer 8
  • Firefox 1.5
  • Opera 7
  • Apple Safari 1.2

Next Article
HTML | DOM Style outlineWidth Property

S

sayantanm19
Improve
Article Tags :
  • Web Technologies
  • HTML
  • HTML-DOM

Similar Reads

    HTML | DOM Style outline Property
    The Style outline property in HTML DOM is used to set or return all outline properties in one declaration. This property draws a line around an element. It sets or returns the one or more border property in short form. The outline can be set the following properties: outline-widthoutline-styleoutlin
    2 min read
    HTML | DOM Style outlineStyle Property
    The Style outlineStyle property in HTML DOM is used to set or return the style of the outline around an element. Syntax: It is used to return the outlineStyle property.object.style.outlineStyleIt is used to set the outlineStyle property.object.style.outlineStyle = value Property Values: none: This i
    2 min read
    HTML DOM Style outlineOffset Property
    The Style outlineOffset property in HTML DOM is used to set or return the outline offset and draw it beyond the border edge. Outlines do not take space, unlike borders. It returns a string that represents the outline-offset property of an element. Syntax:  Return the outlineOffset property.object.st
    1 min read
    HTML | DOM Style outlineColor Property
    The DOM Style outlineColor Property is used to sets or returns the color of the outline around an Element. Syntax: It is used to Return the outlineColor propertyobject.style.outlineColor it is used to Set the outlineColor propertyobject.style.outlineColor = "color|invert|initial|inherit" Property Va
    2 min read
    HTML DOM Style maxWidth Property
    The maxWidth property of HTML DOM sets/returns the maximum width of an element. The maxWidth property affects only block-level elements, absolute or fixed position elements. Syntax: It returns the maxWidth property.object.style.maxWidthIt sets the maxWidth Property.object.style.maxWidth = "none | le
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences