Sitemap

Member-only story

The HTML Tricks I Learned the Hard Way

The simple features I never noticed.

5 min readDec 3, 2025

--

This year, HTML surprised me.

Read Free for non members

I kept running into small UI problems like messy markup, awkward forms, clunky modals.

Every time, I thought I needed more JavaScript to fix things.

But I didn’t.

I started noticing that HTML already had simple features I had never used before.

And once I tried them, my UI instantly felt cleaner and easier to build.

These little discoveries changed the way I work, so I wanted to share them.

Press enter or click to view image in full size
The HTML Tricks I Learned the Hard Way | Tushar Kanjariya
The HTML Tricks I Learned the Hard Way

Keep Markup Safe and Reusable with <template>

I used to rely on innerHTML whenever I needed to repeat a chunk of HTML.

But it gets messy fast and can expose you to injection bugs.

<template> fixed that.

It lets you store HTML that stays hidden until you clone it.

<template id="card-template">
<div class="card">
<h2></h2>
<p></p>
</div>
</template>

<div id="cards"></div>
const template = document.getElementById('card-template');
const container = document.getElementById('cards')…

--

--

Tushar Kanjariya
Tushar Kanjariya

Written by Tushar Kanjariya

Full-Stack Developer sharing insights on code, design, and AI. 6+ Years of Experience in Tech.