What HTML Is and How a Browser Reads It
HTML is not a programming language and the browser is not reading it the way you wrote it. Understanding what actually happens to your markup explains most of the confusion that comes later.
Tags, elements, attributes and the shape of a page - everything an HTML document needs before anything else makes sense.
HTML is not a programming language and the browser is not reading it the way you wrote it. Understanding what actually happens to your markup explains most of the confusion that comes later.
Everyone copies the same starter template without reading it. Here is what each of those seven lines actually does, and what visibly breaks when you leave one out.
Tag, element and attribute get used interchangeably and they are three different things. The distinction is not pedantry, it is what makes error messages readable.
Overlapping tags do not throw an error. The browser rearranges them into something valid instead, and the structure you end up with is rarely the one you wanted.
Why a span ignores the width you set and a div takes the full line. The block and inline distinction explains a large share of early layout confusion.
The head is full of tags people copy without knowing which still do anything. Here is what earns its place and what has been ignored for over a decade.
Comments are not private and whitespace is not ignored. Both facts surprise people, and the second one explains a four pixel gap that has wasted a lot of time.
A small set of attributes work on every element. Choosing between id and class correctly, and knowing what data attributes are for, prevents a lot of later mess.
Four characters genuinely need escaping in HTML. Everything else is a habit from the days before UTF-8, and one entity in particular is badly overused.
Strange symbols where an apostrophe should be are always an encoding mismatch. There are three places the setting has to agree, and all three are easy to check.
Browsers never tell you your markup is broken, they just repair it. A validator is the only thing that will, and its error messages are more readable than they look.
Links and images that work perfectly on your machine and break on the server almost always come down to one wrong slash. Here is what each path form means.