How to Make Text Bold in JavaScript

In this article, we will answer all of your questions about how to make text bold in JavaScript. We’ll start with a basic introduction to the topic, and then move on to more advanced concepts. By the end of this article, you’ll be able to apply bold formatting to your text with ease!

Making text bold in JavaScript is actually very simple. All you need to do is use the “bold” HTML tag, like this.


You may try the following code to generate a strong text in JavaScript.

      <title>JavaScript String bold() Method</title>

         var str = new String("Demo Text");

Alternatively, you can use the “font-size” and “line-height” properties to control the size and spacing of your text, respectively. Here’s an example:

var str = new String("Demo Text");

document.write(str.bold() + "<br />" + str.fontSize(24) + "px" + str.lineHeight(36)); // This will make your text appear in a heavier font weight, with larger text and more spacing between lines

alert(str.bold()); // This will popup an alert with your text bolded

You can also use the “text-transform” property to change the case of your text. Here’s an example:

var str = new String("demoText");

document.write(str); // Outputs "demoText"

document.write(str.bold()); // Outputs "DEMO TEXT"

document.write(str.textTransform("uppercase")); // Outputs "DEMO TEXT"

Hopefully this article has answered all of your questions about how to make text bold in JavaScript! Be sure to check out our other articles for more information on programming and web development. Thanks

Leave a Comment