Member-only story
The HTML Tricks I Learned the Hard Way
The simple features I never noticed.
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.
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')…








