- 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 boldness of the font with JavaScript?
Use the fontWeight property in JavaScript to set the font boldness.
Example
You can try to run the following code to set the boldness of the font with JavaScript −
<!DOCTYPE html> <html> <body> <h1>Heading 1</h1> <p id="myID"> This is Demo Text. </p> <button type="button" onclick="display()">Set Font Family and Font Weight</button> <script> function display() { document.getElementById("myID").style.fontFamily = "verdana,sans-serif"; document.getElementById("myID").style.fontWeight = "800"; } </script> </body> </html>
- Related Articles
- How to set the font size of text with JavaScript?
- How to set the font family for text with JavaScript?
- How to set whether the style of the font is normal, italic or oblique with JavaScript?
- How to set the font to be displayed in small capital letters with JavaScript?
- Set the font style with CSS
- Set the font variant with CSS
- Set the font weight with CSS
- Set the font size with CSS
- Set the font family with CSS
- Shorthand property to set the font with CSS
- Set the font stretch of an element with CSS
- How to set the font size of Matplotlib axis Legend?
- How to preserve the readability of text when font fallback occurs with JavaScript?
- How to set the font size of Entry widget in Tkinter?
- How to set font for text in JTextPane with Java?

Advertisements