Legacy String Methods for Generating HTML


I’m always really excited to see new methods on JavaScript primitives. These additions are acknowledgment that the language needs to evolve and that we’re doing exciting new things. That being said, I somehow just discovered some legacy String methods that you probably should not use but have existed forever. Let’s take a look!

These legacy string methods take a basic string of text and wrap it in an HTML tag of the same name:

"Hello".big() // "<big>Hello</big>"
"Hello".blink() // "<blink>Hello</blink>"
"Hello".bold() // "<b>Hello</b>"
"Hello".italics() // "<i>Hello</i>"
"Hello".link("https://davidwalsh.name") // "<a href="https://davidwalsh.name">Hello</a>"

Native prototypes do not usually remove methods and for good reason – they can break websites! I’m shocked I did not know about these methods before today. It’s always fun to see relics of the web past though!

  • I & # 8217; m an Impostor

    I’m an Impostor

    This is the hardest thing I’ve ever had to write, much less admit to myself. I’ve written resignation letters from jobs I’ve loved, I’ve ended relationships, I’ve failed at a host of tasks, and let myself down in my life. All of those feelings were very …

  • 5 More HTML5 APIs You Didn & # 8217; t Know Existed

    5 More HTML5 APIs You Did Not Know Existed

    The HTML5 revolution has provided us with some awesome JavaScript and HTML APIs. Some are APIs we knew we’ve needed for years, others are cutting edge mobile and desktop helpers. Regardless of API strength or purpose, anything to help us better do our job is a …

  • Pure CSS Slide Up and Slide Down

    Pure CSS Slide Up and Slide Down

    If I can avoid using JavaScript for element animations, I’m incredibly happy and driven to do so. They’re more efficient, do not require a JavaScript framework to manage steps, and they’re more elegant. One effect that is difficult to nail down with pure CSS is sliding up …

  • CSS Fixed Positioning

    CSS Fixed Positioning

    When you want to keep an element in the same spot in the viewport no matter where on the page the user is, CSS’s fixed-positioning functionality is what you need. The CSS Above we set our element 2% from both the top and right hand side of the …



Please enter your comment!
Please enter your name here