Home  >  Article  >  Web Front-end  >  How to display string in monospaced font?

How to display string in monospaced font?

王林
王林forward
2023-09-16 12:25:061160browse

How to display string in monospaced font?

Use JavaScript's fixed() method to display in a fixed-spacing font, just like in the tag.

Example

You can try running the following code to display a string in a fixed-spacing font.

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

   <body>
      <script>
         var str = new String("Hello world");
         alert(str.fixed());
      </script>
   </body>
</html>

The above is the detailed content of How to display string in monospaced font?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete