HTML Fundamentals
Understand what HTML is, how documents are structured, and how browsers interpret HTML.
What Is HTML?
HTML stands for HyperText Markup Language. It is the standard markup language used to describe the structure and meaning of content on the web. HTML is not a programming language because it does not provide general-purpose control flow or algorithms. Instead, it uses elements and attributes to describe content. A browser parses HTML and builds a document tree called the DOM (Document Object Model).
HTML defines what content is and how it is structured. CSS controls presentation, while JavaScript controls behavior.
<!doctype html>\n<html lang="en">\n <head>\n <meta charset="UTF-8">\n <title>Hello HTML</title>\n </head>\n <body>\n <h1>Hello World</h1>\n <p>My first HTML page.</p>\n </body>\n</html>- HTML describes document structure and semantics.
- Browsers convert HTML into a DOM tree.
What does HTML primarily provide?
HTML Document Structure
A well-formed HTML document generally contains <!doctype html>, an <html> root element, a <head> containing metadata, and a <body> containing document content. The lang attribute on <html> should identify the primary language of the document.
<!doctype html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>My Page</title>\n</head>\n<body>\n <h1>Welcome</h1>\n</body>\n</html>- The html element is the document root.
- The head contains metadata while body contains page content.
Where should visible page content normally be placed?
DOCTYPE and Standards Mode
The <!doctype html> declaration tells the browser to use modern standards mode. It is not an HTML element. Omitting the declaration can cause browsers to enter quirks mode, where historical rendering behavior may affect layout and CSS.
Start modern HTML documents with <!doctype html> to avoid accidental quirks-mode rendering.
- DOCTYPE is a declaration, not an HTML element.
- Modern documents should use <!doctype html>.
What is the purpose of <!doctype html>?