Live data from Hacker News

Tags to make HTML work like you expect

blog.jim-nielsen.com

221–230 of 248 posts

Re: Tags to make HTML work like you expect

#221
the lang="en" always irritates me.

What if the page has mixed language content?

e.g. on the /r/france/ reddit. The page says lang="en" because every subreddit shares the same template. But actual content were generated by French speaking users.

Re: Tags to make HTML work like you expect

#222
post #221

the lang="en" always irritates me. What if the page has mixed language content? e.g. on the /r/france/ reddit. The page says lang="en" because every subreddit shares the same template. But actual content were generated by French speaking users.

You can add lang attributes to elements too!

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...

Re: Tags to make HTML work like you expect

#223
post #221

the lang="en" always irritates me. What if the page has mixed language content? e.g. on the /r/france/ reddit. The page says lang="en" because every subreddit shares the same template. But actual content were generated by French speaking users.

This is one of the great parts of the web: you can tag every element with the global lang attribute and have things work the way you expect.

For example, you can have CSS generate the appropriate quotation marks even in nested contexts so you can painlessly use tags to markup scholarly articles even if the site itself is translated and thus would have different nested quotation marks for, say, the French version embedding an English quote including a French quote or vice versa.

In your Reddit example, the top level page should be in the user’s preferred site language with individual posts or other elements using author’s language: …

Re: Tags to make HTML work like you expect

#224
post #221

the lang="en" always irritates me. What if the page has mixed language content? e.g. on the /r/france/ reddit. The page says lang="en" because every subreddit shares the same template. But actual content were generated by French speaking users.

lang="" if you don't know what language your page will be in. , and then on whatever other language content. Content from users that aren't tagged to be in a specific language doesn't really fit into this system though.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...

Re: Tags to make HTML work like you expect

#225
post #19

Anyone else prefer to use web components without bundling? I probably should not admit this, but I have been using Lit Elements with raw JavaScript code. Because I stopped using autocomplete awhile ago. I guess not using TypeScript at this point is basically the equivalent for many people these days of saying that I use punch cards.

Even with TS, if I’m doing web components rather than a full framework I prefer not bundling. That way I can have each page load the exact components it needs. And with http/2 I’m happy to have each file separate. Just hash them and set an immutable cache header so it even when I make changes the users only have to pull the new version of things that actually changed.

This.

I'm old enough to have a first hand experience of building a Flash website that required to load couple hundred tiny xml files for configuration only to find out that some ~300kb was taking couple of minutes to load because of limited connection pool in old http.

Back then bundling and overly complicated build steps were not yet invented, so instead of serving one large XML (which would work out of the box, as there was a root xml and certain nodes instead of having data were linking to external files) I quickly decided to implement zip compression and bundle the package that way.

Fast forward to 2025 when most devs need an external library to check if number isEven and the simplest project need a toolchain that's more complicated that the whole Apollo project.

Re: Tags to make HTML work like you expect

#226
post #59

Earlier quoted context omitted.

I wish `dang` would take some time to go through the website and make some usability updates. HN still uses a font-size value that usually renders to 12px by default as well, making it look insanely small on most modern devices, etc. At quick glance, it looks like they're still using the same CSS that was made public ~13 years ago: https://github.com/wting/hackernews/blob/5a3296417d23d1ecc90...

Setting aside the relative merits of 12pt vs 16pt font, websites ought to respect the user's browser settings by using "rem", but HN (mostly[1]) ignores this. To test, try setting your browser's font size larger or smaller and note which websites update and which do not. And besides helping to support different user preferences, it's very useful for accessibility. [1] After testing, it looks like the "Reply" and "Hel…

Side note: pt != px. 16px == 12pt.

Re: Tags to make HTML work like you expect

#227

I'm not a web developer, so if someone can please enlighten me: Why does this site, and so many "modern" sites like it have it so that the actual content of the site takes up only 20% of my screen? My browser window is 2560x1487. 80% of the screen is blank. I have to zoom in 170% to read the content. With older blogs, I don't have this issue, it just works. Is it on purpose or it is it bad css? Given the title of the…

Often times that is to create a comfortable reading width. ( https://ux.stackexchange.com/questions/108801/what-is-the-be... )

This breaks so hard with my own preferences it hard to believe it to be true, and relevant studies aren't all that convincing. The few websites I find that go to 150/200+ character lines are a blessing to read when I do. I only get to do this on my desktop on very odd sites or completely unstyled HTML pages (and there you don't get line-spacing, which is something I do want. I should probably write a script to fix that), and Hacker News, and I never want that to go away.

This wouldn't be the first thing I'm just weird about. Similarly, I find reading justified text to be just horrible, as I constantly lose track of what line I'm on. This one I believe has been debunked and raised as a genuine accessibility concern, but not all parts of the world have gotten around to recognising that. I'm also not a fan of serifed fonts, even in books. I'm not sure if there have been any studies made about that, as the serifs are supposed to be there to aid reading when printed on paper, but I consistently find a good sans-serif font to be better in all cases.

Re: Tags to make HTML work like you expect

#228
post #19

Anyone else prefer to use web components without bundling? I probably should not admit this, but I have been using Lit Elements with raw JavaScript code. Because I stopped using autocomplete awhile ago. I guess not using TypeScript at this point is basically the equivalent for many people these days of saying that I use punch cards.

> not using TypeScript at this point is basically the equivalent for many people these days of saying that I use punch cards

I very much enjoy writing no-build, plain vanilla JS for the sake of simplicity and ability to simply launch a project by dragging HTML file onto a browser. Not to mention the power of making changes with notepad instead of needing whole toolchain on your system.

Re: Tags to make HTML work like you expect

#229

> ` ` The author might consider instead: ` `

It's time for an "en-INTL" (or similar) for international english, that is mostly "en-US", but implies a US-International keyboard and removes americanisms, like Logical Punctuation in quotes [1]. Then AI can start writing for a wider and much larger public (and can also default to regular ISO units instead of imperial baby food). Additionally, it's kind of crazy we are not able to write any language with any keyboar…

en-DK is used for this in some cases, giving you English, but with metric units and an ISO keyboard among other things.

A dedicated one for International English, or heck, even just EU-English, would be great.

The EU websites just use en from what I can tell, but they also just use de, fr, sv, rather than specifying country (except pt-PT, which makes sense, since pt-BR is very common, but not relevant for the EU).

Re: Tags to make HTML work like you expect

#230
post #221

the lang="en" always irritates me. What if the page has mixed language content? e.g. on the /r/france/ reddit. The page says lang="en" because every subreddit shares the same template. But actual content were generated by French speaking users.

lang="" if you don't know what language your page will be in. , and then on whatever other language content. Content from users that aren't tagged to be in a specific language doesn't really fit into this system though. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...

That sounds good in theory. On bsky.social you are supposed to choose a lang before posting.

But again there's mixed language issue

Or do users even bother to choose the correct lang?

Post reply on HN