Hacker News new | ask | show | jobs
by omnimike 947 days ago
The example given in the post was using <div>s rather than semantic HTML elements. The motivation for the principle of using "semantic HTML elements" comes from the lofty ideals of the Semantic Web[0]. However, these principles didn't come from best practice. Instead, someone (Tim Berners-Lee) thought that it was a cool idea and tried to convince everyone of it without demonstrating that it could actually deliver on any of the promises it made. The argument instead is that principles should be based on what is proven to work, rather than what sounds good in theory. I agree with the sentiment in the post.

[0] https://en.wikipedia.org/wiki/Semantic_Web

1 comments

Thanks, I really didn’t get what they meant with the example they were using.

Out of curiosity why is writing everything as a single element type more ergonomic? I’ve not done frontend web dev in a while and using <p> <h1> and so on seems like it would be more ergonomic to express intent.

The reason why it's so tempting to just use `<div>` everywhere is that `<div>` elements have very simple and predictable behaviour with regards to styling, composition and event handling.

Same cannot be said for a lot of other HTML elements, which often have bizarre and inconvenient rules when it comes to style-ability, or nest-ability.