HACKER Q&A
📣 tagawa

HTML actions that replace JavaScript/CSS?


Following on from today’s HTML redirects post ( https://news.ycombinator.com/item?id=35670325 ), I was wondering what other actions exist within HTML, that many devs use JavaScript or CSS for.

The “summary” element for showing/hiding details springs to mind. What else is there?


  👤 doodlesdev Accepted Answer ✓
There is a trick for collapsible sidebars where you can use a checkbox and style the sidebar display conditionally based on the checkbox :checked pseudo-selector, AFAIK this is the only way to make this style of sidebar without JavaScript. [0][1][2]

[0]: https://www.digitalocean.com/community/tutorials/css-collaps...

[1]: https://webdevtrick.com/css-sidebar-menu/

[2]: https://webdevtrick.com/demos/css-sideout-menu/


👤 fogzen
The datalist element, which can be used for browser native autocomplete of input options https://developer.mozilla.org/en-US/docs/Web/HTML/Element/da...

👤 kypro
There's quite a lot you can do with just CSS using hidden inputs for state and clever selectors to dynamically update content. It's possible to create a non-JS tab implementation using just hidden inputs and CSS for example, although I wouldn't recommend it.

You can also do basic client-side form validation with just HTML (although you'll need some CSS to display the errors I think).

The summary element is a good example and the first that came to my mind. Most of the things I can think of would require at least some CSS, or are already reasonably well known.


👤 tagawa
Just thought of another couple – the input types "date" and "color".