Tech News
← Back to articles

Don't Forget These Tags to Make HTML Work Like You Expect

read original related products more articles

I was watching Alex Petros’ talk and he has a slide in there titled “Incantations that make HTML work correctly”.

This got me thinking about the basic snippets of HTML I’ve learned to always include in order for my website to work as I expect in the browser — like “Hey I just made a .html file on disk and am going to open it in the browser. What should be in there?”

This is what comes to mind:

< html lang = "en" > < meta charset = "utf-8" > < meta name = "viewport" content = "width=device-width,initial-scale=1.0" >

Why each?

doctype

Without , browsers may switch to quirks mode, emulating legacy, pre-standards behavior. This will change how calculations work around layout, sizing, and alignment.

is what you want for consistent rendering. Or if you prefer writing markup like it’s 1998. Or even if you eschew all societal norms. It’s case-insensitive so they’ll all work.

html lang

< html lange = "en" >

... continue reading