Live data from Hacker News

You can make up HTML tags

maurycyz.com

141–150 of 202 posts

Re: You can make up HTML tags

#141

But there's no real reason to, and it just adds confusion around which elements are semantic -- bringing formatting, functionality, meaning to screen readers and search engines, etc. -- vs which are custom and therefore carry no semantic meaning. If there's no native semantic tag that fits my purposes, I'd much rather stick to a div or span as appropriate, and identify it with one (or more) classes. That's what class…

Why would it create confusion? Because you're not familiar with it? Things change..

Because there are so many native elements to keep track of now.

If you see an unfamiliar tag that has a reasonably simple name, you simply don't know if it's native or for formatting.

That's confusing. It's taking two categories of things and mixing them so you can't tell them apart.

Re: You can make up HTML tags

#142

But there's no real reason to, and it just adds confusion around which elements are semantic -- bringing formatting, functionality, meaning to screen readers and search engines, etc. -- vs which are custom and therefore carry no semantic meaning. If there's no native semantic tag that fits my purposes, I'd much rather stick to a div or span as appropriate, and identify it with one (or more) classes. That's what class…

So, the article doesn't discuss this, but there's actually a really good reason to make up and use custom elements: the browser can hydrate their dynamic behaviour automatically. For example, suppose you have: Expand And you have some JS that handles the expander's behaviour: for (const expander of document.querySelectorAll('.expander')) { const btn = expander.querySelector('button'); btn.addEventListener('click', ()…

That's good to know, and I even did say that custom UX widgets are a case where custom tag names makes more sense conceptually.

I'm really just pushing back on the idea of using them for CSS formatting purposes of general text and layout instead of classes.

Re: You can make up HTML tags

#143
If you try this with React + TypeScript, expect some paper cuts. You’ll need a .d.ts file for your custom elements so TypeScript’s JSX checker accepts them. Even then, eslint can complain about namespaces.

JSX solves the "named containers" problem in code:

  
    ...
  

But the tags don't show up in the real DOM. Everything compiles to plain divs. Whether that matters depends on if you care about inspecting the rendered HTML or just the source code.

Re: You can make up HTML tags

#144

Earlier quoted context omitted.

There is N-th child selector with filter, for example you can write :nth-child(3 of .red) https://waspdev.com/articles/2025-06-29/css-features-web-dev...

Cool! I guess this now also makes nth-of-type superfluous.

IMHO this also makes custom tags no longer very useful beyond custom HTML components (JS is also required for that). The standard tags provide good semantics, SEO and accessibility out of the box.

Re: You can make up HTML tags

#147
post #87

Earlier quoted context omitted.

So, the article doesn't discuss this, but there's actually a really good reason to make up and use custom elements: the browser can hydrate their dynamic behaviour automatically. For example, suppose you have: Expand And you have some JS that handles the expander's behaviour: for (const expander of document.querySelectorAll('.expander')) { const btn = expander.querySelector('button'); btn.addEventListener('click', ()…

this.querySelector will return nothing when you define this Web Component before (light)DOM is parsed, because the connectedCallback fires on the opening tag. Above code will only work when the Web Component is defined after DOM has parsed; using "defer" or "import" makes your JS file execute after DOM is parsed, you "fixed" the problem without understanding what happened. I blogged about this long time ago: https://…

Well, that's why I include JS files at the bottom of my HTML body, to make sure to avoid exactly this problem: https://github.com/yawaramin/dream-html-ui/blob/92f2dfc51b75...

Re: You can make up HTML tags

#149
post #82
post #30

Many years ago, I decided to reinvent the `blink` tag, because the monsters who make browsers removed support for it. I didn't know you could just make up tags, but I figured I'd give it a shot, and with a bit of jquery glue and playing with visibility settings, I was able to fix browsers and bring back the glorious blinking. I was surprised you could just do that; I would have assumed that the types of tags are fina…

Talking about this, I am still sad Flash got removed from the web. Nothing to replace it with to afaik.

Although Flash really sucked as a technology, it did inspire a lot of visual artistry on the web. Half of the cool stuff you saw on StumbleUpon was made with Flash by people who weren't proficient with JS/CSS, which weren’t capable enough to achieve the same results anyway.
Post reply on HN