Skip to content

Create a HTML tt element from a JavaScript string

This JavaScript tutorial explains how to create a HTML <tt> tag using the string method called fixed() with syntax and examples.

In JavaScript, fixed() is a string method that is used to create the HTML <tt> element. Because the fixed() method is a method of the String object, it must be invoked with an instance of the String class.

Syntax

string.fixed();

Example

var myString = 'Poopcode';

console.log(myString.fixed()); // <tt>Poopcode</tt>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.