|
|
|
|
|
by TonyAlicea10
25 days ago
|
|
> You want a change to a part of text? Span. You haven’t read the HTML spec. There are an incredible amount of elements, including for changing just a piece of text (b, i, strong, em, and many more). Plus elements for visual aspects like images. You need divs and spans for extra structure that isn’t there for anything but visual purpose. For things you wouldn’t describe to someone who couldn’t see the page. That’s a lot less than you think. HTML authoring and choosing the right elements can be fun. But you have to stop thinking visually and start thinking semantically. |
|
That is, a dearth of them. Most of them are still there defining basically just text content.
> Including for changing just a piece of text (b, i, strong, em, and many more)
Not as many as you'd think. If I need to layout text in a certain way and mark some of it in a certain way, there's nothing better than <span>.
> But you have to stop thinking visually and start thinking semantically.
This sentence carries less meaning than you think it does.
E.g. there's the <article> tag. It was literally originally proposed for text content only: https://www.w3.org/WAI/GL/wiki/Using_HTML5_article_element The spec twists this to become more generic and encompassing all other content, and still does not escape framing it as mostly text-ish elements: https://html.spec.whatwg.org/multipage/sections.html#the-art...
And here's MDN intro saying "oh, yes, if you want cards for your product catalog, or an interactive widget, use <article>" https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...
Yup. "article" is "semantic" to represent cards in a product catalog.
You basically have to construct a parallel hierarchy of elements in your head with specific behaviours that doesn't match what element names mean, or used to mean.
There's nothing fun in figuring out 30 years of history of a largely outdated tech being twisted to conform to the new world of complex layouts and interactions.