HTML is declarative
The beautiful thing about HTML is that it’s declarative. You just tell the browser what should appear on the page, and it makes it happen. If I want to add a top-level heading to the page, all I need to do is include an
There are no complicated steps in which I need to tell the browser exactly how to create this element, what it should do, or what kind of content it describes. That’s all taken care of for me automatically.
H1 element to show its text content when clicked, I have to manually set that up:
This is a simple example, but it’s inherently more difficult. It requires you to think through the logic and implementation of the code.
It also requires more technical knowledge. Even for a simple example like this, you have to know how to:
- Create a variable
- Select an element from the DOM
- Write a function
- Log data to the console
- Add an event listener
You tell the framework what your application should look like based on its current state. Then the framework handles all the DOM interactions for you whenever the state changes.
If you want to go down this route, I recommend a much more lightweight library like Reef. That’s my personal favourite, but there are other good ones like Alpine, Preact, and Svelte.
For more on state-based UI, check out these posts from my friend Chris Ferdinandi:
- Refactoring a vanilla JS app with state-based UI
- State-based UI vs. manual DOM manipulation
- State-based UI with vanilla JS
There’s no shame in preferring HTML and CSS
Those who say HTML and CSS aren’t real programming languages tend to be absolutely dog shit at them. Just ask them to center an element on the page and watch them squirm.
Be proud of your unique skills!
If you have questions, feedback, or any other suggestions, please do email me. I'd love to hear from you!