HTML is propably the most widely known and successful document markup language today. In the 2 decades since Tim Berners Lee invented the 'lingua franca' of the web, much has changed about the way we write HTML. In the early 90's, HTML was little more than a way to structure text and link documents to each other. There were no animations, no videos, no Javascript... just elements to mark headlines, paragraphs, images and of course links.
When talking about 'correct HTML', we have to distinguish between grammar and semantics.
Grammatically correct means, that the document conforms to the rules of grammar given for a certain document type. The document type specifies, what is considered valid HTML and which tags and attributes you can use in your document. Errors in your markup will cause the browser to switch to 'quirks mode', where it guesses what you might have meant. Since computers are the most stupid things on earth, you'll want to avoid this at all costs.
Semantical correctness means, that the elements of the language are used for what they were intended. For example, a paragraph must be enclosed in <p>
tags, not <div>
s. Likewise, a headline must be one of <h1>
to <h6>
and not something like <strong><span class="header3">...</span></strong>
. After all, a headline is not intended to make a text bold. The real meaning of a tag like <h1>
is 'this is a headline'.
In the early days of the world wide web, designers used to (ab)use table
s for layout purposes. Since there was no other way to position elements exactly, this didn't count as sin but was rather seen as good practise. However, today it can be said, that there really is no need to abuse tables for layout purposes.
Why is it wrong to use a table (or several) to format a page? There are several reasons:
Some might think "if it's not broken, why fix it?" or even "it has worked all those years. Why bother?" but I really enjoy the freedom web standards provide me and while you could certainly use an old, rusty, soft-metal screwdriver to screw shiny new screws into a wall, I really prefer to use my brand new electric screwdriver instead. Also, the screws will be straighter and I won't injure my hands.