How to create a bold text using JavaScript?


To create a bold text using JavaScript, use the bold() text. This method causes a string to be displayed as bold as if it were in a <b> tag.

Example

You can try to run the following code to create a bold text with JavaScript −

Live Demo

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

   <body>
      <script>
         var str = new String("Demo Text");
         document.write(str.bold());
         alert(str.bold());
      </script>
   </body>
</html>

Updated on: 15-Jun-2020

16K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements