How to change font-weight of a text using JavaScript ? Last Updated : 25 Dec, 2020 Comments Improve Suggest changes Like Article Like Report In this article, we will set the font-weight of a text dynamically using JavaScript. Ti change the font weight dynamically, we use HTML DOM Style fontWeight property. Syntax: object.style.fontWeight = "value" Property Values: normal: The font weight is the default value.lighter: The font weight is the lighter than normal.bold: The font weight is bolder than normal.bolder: The font weight is bolder than bold.value: It defines from 100 to 900 where 400 is normal value.initial: It sets to its default font weight.inherit: It inherits this property from its parent element. Example: HTML <!DOCTYPE html> <html> <head> <title> How to change font-weight of a text using JavaScript? </title> </head> <body style="text-align: center;"> <h1 style="color: green"> GeeksforGeeks </h1> <h2> How to change font-weight of <br>a text using JavaScript? </h2> <p id="sudo">Welcome to GeeksforGeeks</p> <br> <button type="button" onclick="myGeeks()"> Click to change </button> <script> function myGeeks() { document.getElementById("sudo") .style.fontWeight = "bold"; } </script> </body> </html> Output: Before Click the Button: After Click the Button: Supported Browsers: Google ChromeInternet ExplorerMozilla FirefoxOperaSafari Comment More infoAdvertise with us Next Article How to change font-weight of a canvas-type text using Fabric.js? V vkash8574 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to change the text of a label using JavaScript ? Changing the text of a label using JavaScript involves selecting the label element and updating its textContent or innerHTML property. This allows you to modify the displayed text dynamically, often in response to user interactions or changes in data, enhancing interactivity and responsiveness.Below 2 min read How to change the text of a label using JavaScript ? Changing the text of a label using JavaScript involves selecting the label element and updating its textContent or innerHTML property. This allows you to modify the displayed text dynamically, often in response to user interactions or changes in data, enhancing interactivity and responsiveness.Below 2 min read How to change the text of a label using JavaScript ? Changing the text of a label using JavaScript involves selecting the label element and updating its textContent or innerHTML property. This allows you to modify the displayed text dynamically, often in response to user interactions or changes in data, enhancing interactivity and responsiveness.Below 2 min read How to change font-weight of a canvas-type text using Fabric.js? One can change the font-weight of a canvas-type using Fabric.js which adds versatility and style to the web applications and graphic design. It provides an efficient method to manipulate text properties such as font weight dynamically, which enhances the presentation and readability of the text elem 3 min read How to change font-weight of a canvas-type text using Fabric.js? One can change the font-weight of a canvas-type using Fabric.js which adds versatility and style to the web applications and graphic design. It provides an efficient method to manipulate text properties such as font weight dynamically, which enhances the presentation and readability of the text elem 3 min read How to change font-weight of a canvas-type text using Fabric.js? One can change the font-weight of a canvas-type using Fabric.js which adds versatility and style to the web applications and graphic design. It provides an efficient method to manipulate text properties such as font weight dynamically, which enhances the presentation and readability of the text elem 3 min read Like