Tired of typing out the same HTML all the time? I'm talking about those card layouts that you see everywhere, or buttons you keep copy-pasting.
Guess what? You can actually make your own HTML tags that do what you want. These are called Web Components, and they're not as hard as they sound.
What's a Web Component?
Think of it like this: You could buy a monitor, keyboard, mouse, and headset separately for your gaming setup. Or, you could grab a gaming bundle where it all just works together.
Web Components let you make your own HTML bundles.
Instead of this:
<h3>Some Title</h3> <p>Some content here...</p>
You can write:
>Some content here...
Yep, that's all.
How I Used to Deal With This
Before Web Components, I was copying HTML all over the place. Then I'd forget which CSS went where. I'd move something and suddenly half the page would break. Then I'd waste an hour trying to fix it. Ugh!
Now I just make the component once and drop it in wherever I need it.
Three Ways to Make Web Components
- Basic Ones These act like normal HTML tags, but you name them whatever you want. Your page's CSS can still style them.
class MyCard extends HTMLElement {
connectedCallback() {
this.innerHTML = <h2>Hello World</h2>
;
}
}
customElements.define('my-card', MyCard);
- Shadow DOM Ones These put your component in its own little world. Styles stay in, and everything else stays out.
class MyCard extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.shadowRoot.innerHTML =
;
h2 { color: blue; }
<h2>Hello World</h2>
}
}
- Slot Ones These are like templates where you can swap out bits of content; pretty useful.
class MyCard extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.shadowRoot.innerHTML = `
/* your styles */
`;
}
}
Making These From Scratch Can Be Hard
I've tried doing that before. It's tough! You gotta:
Write class definitions (so boring)
Figure out lifecycle methods (huh?)
Deal with Shadow DOM (gets tricky)
Make sure tag names are written a specific way (hyphens!)
Manually test (takes ages)
I usually give up, lol, and just use another div.
But I Found a Tool That Works
Then I found this tool that does all the boring legwork: Free HTML Web Component Maker.
https://www.webutilitylabs.com/p/free-html-web-component-maker-live-no.html
What makes it good:
Live preview - See it as you build!
Ready-to-go code - HTML, JavaScript, and CSS are all made for you
No signup needed - Just use it, its free
Three types - Basic, Shadow DOM, or Slots, just pick one!
No mistakes - Checks your tag names and helps correct them
It's like having someone else do the boring stuff while you have fun.
How I Personally Use It
When I need a component:
I open the tool and think of a name (gotta have a hyphen!)
Write the HTML - Just the basic content I want in the tag
Add CSS - Make it look good
Pick Shadow DOM - I use this whenever I can
Copy the code - Three boxes with all the code already written
Paste it into my project - Done!
The live preview is what I like best. You see exactly what you’re doing.
Example
I had to make a section for some wireless headphones last week. Here's how I did it:
Named it headphones-card
Added this HTML:
Wireless Headphones
$9.99
Buy Now
Added some CSS:
.product {
border: 1px solid #333;
border-radius: 8px;
padding: 1rem;
text-align: center;
max-width: 280px;
background: #f8f8f8;
}
.price {
font-size: 1.3em;
color: #e74c3c;
font-weight: bold;
}
button {
background: #27ae60;
color: white;
border: none;
padding: 0.6rem 1.2rem;
border-radius: 4px;
cursor: pointer;
}
Picked Shadow DOM
Copied the code
Now I can use > anywhere, and it looks great.
Before the tool, that would've taken me an hour. The tool did it in like 10 minutes.
Browser Support
It works in all the up-to-date browsers:
Chrome and Edge
Firefox
Safari
Mobile browsers
Tell those that use Internet Explorer to upgrade from the stone age lol.
Things I Noticed
Tag names: Must use kebab-case (hyphens). headphones-card is good, headphonescard is bad.
Shadow DOM vs Basic: Shadow DOM keeps styles separate. Basic lets page styles affect the component. I mostly use Shadow DOM.
Slots: When you need content that is flexible, use slots. They're just placeholders.
Keep it easy: Don't build everything at once. Start simple, then add things later.
Make each component do one thing, and do it well.
When These Aren't Right for You
Don't use Web Components if:
You already use React or Vue
You just need basic HTML
You need to handle tricky data
Your team doesn't know JavaScript
Sometimes a regular div works fine.
To Sum It Up
Web Components are pretty great, and this tool makes them easy to build. Instead of searching online, just use the builder.
https://www.webutilitylabs.com/p/free-html-web-component-maker-live-no.html
Labs tool gets rid of the parts that are annoying. This thing just works.
Next time you catch yourself copy-pasting HTML, give it a try! Bet you'll save time.
I've been using it for months, and it's made my job way simpler. No more struggling with boilerplate—just build what you want, and the tool handles the rest!
Have you ever tried making Web Components? How did it go? Tell me if this tool is helpful!
Top comments (0)