
- 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 all the border top properties in one declaration with JavaScript?
To set all the border top properties in a single declaration, use the borderTop property. With this property, you can set the border-top-width, border-top-style, and border-top-color property.
Example
You can try to run the following code to learn how to work with border-top properties in JavaScript −
<!DOCTYPE html> <html> <head> <style> #box { border: thick solid gray; width: 300px; height: 200px } </style> </head> <body> <div id="box">Demo Text</div> <br><br> <button type="button" onclick="display()">Change top border</button> <script> function display() { document.getElementById("box").style.borderTop = "thick solid #000000"; } </script> </body> </html>
- Related Articles
- How to set all the border left properties in one declaration with JavaScript?
- How to set all the border right properties in one declaration with JavaScript?
- Set all the top border properties in one declaration using CSS
- How to set all the border bottom properties in one declaration in JavaScript DOM?
- How to set all the outline properties in one declaration with JavaScript?
- How to set all the background properties in one declaration with JavaScript DOM?
- How to set border width, border style, and border color in one declaration with JavaScript?
- How to set all outline properties in a single declaration with JavaScript?
- How to set all the four border radius properties at once with JavaScript?
- How to set the CSS margin properties in one declaration?
- Set all border-radius properties with CSS
- How to set the style of the top border with JavaScript?
- How to set the color of the top border with JavaScript?
- How to set the width of the top border with JavaScript?
- How to set listStyleImage, listStylePosition, and listStyleType in one declaration with JavaScript?

Advertisements