Live data from Hacker News

You can make up HTML tags

maurycyz.com

81–90 of 202 posts

Re: You can make up HTML tags

#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.

Re: You can make up HTML tags

#83
post #16

the comments here informing us they default to behaving like instead of like is the biggest disappointment of my day so far

See my other comment: you can set default styles using

:where(:not(:defined)) { display: block }

Re: You can make up HTML tags

#84
post #24

Earlier quoted context omitted.

This example also shows a weakness of custom tags compared with using the class attribute. An element can have only single name but may have several classes. And as classes are unordered set, one cannot in general emulate that with several elements as the nesting introduces an order absent in the class list.

Good use case for @container, @scope and :has(), where you forgo class definitions and use --custom-properties on the parent scope/container which are inherited downwards based on the existence of a scoped DOM pattern/container query, or 'upwards' by using a :has(child-selector) on the parent. Although be sure to avoid too many :has(:nth-child(n of complex selector)) in case of frequent DOM updates.

[flagged]

Re: You can make up HTML tags

#85
post #77
post #65

That's how https://janetdocs.org/ does syntax highlighting: ``` ( defn bench `Feed bench a wrapped func and int, receive int for time in ns` [ thunk times ] ( def start ( os/clock :cputime :tuple )) ```

That's kinda cool but the article addresses a major concern with this strategy that is not addressed here. Which is that many of these tags (e.g. , , etc) might someday become part of the HTML standard. The article states that anything with a dash is guaranteed not to be and another commenter here shared their strategy that involved a naming convention like , , etc. Perhaps substituting x for j would make sense and a…

Fair, I had a collision with for a month before someone else noticed some minor error.

Re: You can make up HTML tags

#86
post #24

... a bunch more HTML ... Just one quibble over this specific example (not the broader concept, which is sound): it probably didn’t have to be div soup to begin with. Something like this may have been more reasonable: ... a bunch more HTML ...

This example also shows a weakness of custom tags compared with using the class attribute. An element can have only single name but may have several classes. And as classes are unordered set, one cannot in general emulate that with several elements as the nesting introduces an order absent in the class list.

Not trying to be rude but to me that is the essence of composition which feels perfect to me

Re: You can make up HTML tags

#87

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', ()…

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://dev.to/dannyengelman/web-component-developers-do-not...

Re: You can make up HTML tags

#88
> If you include hyphens in the name, you can guarantee that your tag won’t appear in any future versions of HTML.

Which future version? Is there something I'm missing? I'd like to have html6 that has feature parity with native, but I'm afraid we got html5 and just stopped there. And if there will be an html6 why can't we just state "use version 5 in this document" so there won't be any name clashing between supported and custom tags?

Re: You can make up HTML tags

#89

> If you include hyphens in the name, you can guarantee that your tag won’t appear in any future versions of HTML. Which future version? Is there something I'm missing? I'd like to have html6 that has feature parity with native, but I'm afraid we got html5 and just stopped there. And if there will be an html6 why can't we just state "use version 5 in this document" so there won't be any name clashing between supporte…

HTML 5 still gets new features all the time: https://github.com/whatwg/html

But they'll never add new standard tags with hyphens.

Re: You can make up HTML tags

#90
post #4

By default, they will behave like spans. You can customize it using the Custom Element API: https://developer.mozilla.org/en-US/docs/Web/API/Web_compone...

I would rather use semantic elements for the examples like the one in the article and use web components/custom elements where appropriate.

Web Components are underrated for sure. I had a need for a custom element[0] and it was not difficult to implement.

[0]: https://github.com/zikani03/hypalink

Post reply on HN