Understanding the structure of HTML documents and how to organize them properly
DOCTYPE Declaration
<!DOCTYPE html>
declaration tells the browser that the document is an HTML5 document.HTML Element
<html>
element is the root element that contains all other HTML elements.Head Section
<head>
element contains meta-information about the document, such as its title, character encoding, viewport settings, and links to external resources.Body Section
<body>
element contains all the content that is visible on the web page, such as text, images, links, and other elements.<!DOCTYPE>
Declaration<!DOCTYPE>
declaration must be the very first thing in your HTML document, before the <html>
tag. It is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.
<!DOCTYPE html>
, <!DOCTYPE HTML>
, and <!doctype html>
are all valid. However, lowercase is commonly used in HTML5.<html>
Element<html>
element is the root element of an HTML page. All other elements must be descendants of this element.
lang
attribute specifies the language of the document, which helps search engines and browsers. It’s a good practice to always include this attribute.
<head>
Section<head>
section contains meta-information about the document that isn’t displayed directly on the page. This includes:
<title>
element is required in all HTML documents and defines the title of the document. This title appears in the browser’s title bar or tab.
<head>
section is also where you link to external resources like CSS stylesheets, JavaScript files, and fonts.
<body>
Section<body>
element contains all the content that is visible on the web page. This is where you place your text, images, links, and other visible elements.
<h1>
through <h6>
) and sectioning elements.
<h1>
directly to <h3>
), as this can confuse screen readers and harm accessibility.<section>
, <article>
, and <div>
defer
/async
attributes)