Do I need to know CSS or JavaScript before learning HTML?
No. HTML is the right starting point. It describes what your content is — a heading, a paragraph, a list, a form field. CSS then describes how it looks and JavaScript what it does. Learning HTML first means the other two have something to attach to, and it means your page still works when CSS or JavaScript fails to load.
What is the difference between HTML and HTML5?
HTML5 was the fifth major revision of the language, and it introduced semantic elements such as <header>, <nav>, <article> and <footer>, native <video> and <audio>, the <canvas> element, new form input types and browser APIs. HTML is now a "living standard" with no version numbers — features are added continuously. In practice, "HTML" and "HTML5" mean the same thing today. See our HTML5 features guide.
Which doctype should I use?
Just <!DOCTYPE html>. It is case-insensitive, needs no DTD URL, and puts every browser into standards mode. The long XHTML and HTML 4 doctypes are obsolete. It must be the very first thing in the file — anything before it, even a blank line with a byte-order mark, can trigger quirks mode.
Should I use <div> or a semantic element?
Use a semantic element whenever one describes your content: <nav> for navigation, <main> for the primary content, <article> for a self-contained piece, <aside> for tangential content. Screen readers expose these as landmarks, so users can jump straight to them. Reach for <div> only when you need a container purely for styling and no semantic element fits.
Why does my page look different in different browsers?
Usually one of three reasons. Each browser ships its own default stylesheet, so unstyled margins and font sizes differ — a CSS reset fixes that. A feature you used may not be supported everywhere; check Can I use. Or your markup has an error that each browser recovers from differently — run it through the W3C checker first.
Is HTML validation still worth doing?
Yes. Browsers are forgiving, which is exactly the problem: invalid markup renders something, just not always what you meant, and not the same thing in every browser. Validation catches unclosed tags, duplicate id attributes and invalid nesting in seconds. It also catches accessibility problems such as a missing alt attribute.
Do I need alt text on every image?
Every <img> needs an alt attribute, but not every one needs text in it. If the image conveys information, describe that information. If it is purely decorative, use alt="" — an empty value tells screen readers to skip it, whereas omitting the attribute entirely makes some read out the filename.
How do I make a responsive page?
Start with <meta name="viewport" content="width=device-width, initial-scale=1.0"> in the <head> — without it, mobile browsers pretend to be desktop-width and shrink everything. Then use fluid widths, flexible images and CSS media queries to adjust the layout. Our responsive design guide walks through each step.
Can I use HTML form validation instead of JavaScript?
For most forms, yes. Attributes such as required, type="email", min, max, pattern and maxlength give you validation and accessible error messages with no scripting. Add JavaScript when you need custom messages, cross-field rules or checks against a server. Always validate on the server too — client-side validation is a convenience, not a security control. See form validation.
Are the code examples on this site free to use?
Yes. Every code example here can be copied into your own projects, personal or commercial, with no attribution required. The surrounding written explanations remain our copyright. See our terms of service.
Still stuck?
Work through the relevant guide — HTML Basics, Forms or Accessibility — or try the idea directly in our live editor. The resources page lists the reference sites and validators we trust.