HTML Basic Structure
The basic structure of an HTML document consists of several elements that define the overall layout and content of a web page. Here's an example of the basic structure of an HTML document:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Your Page Title</title> </head> <body> <!-- Your page content goes here --> </body> </html>
Here's an explanation of the above example:
- <!DOCTYPE html>: This determines that it is an HTML document.
- <html lang="en">: This is the opening of the html tag <html> and the last line is closing of the html tag </html>. This is the root element of the HTML document with the language attribute set to "en" (English).
- <head>: This is the head tag and it contains metadata such as character set, viewport settings, and the page title.
- <meta charset="UTF-8">: This tag specifies the character encoding.
- <meta name="viewport" content="width=device-width, initial-scale=1.0">: This tag sets the viewport properties for responsive design.
- <title>Your Page Title</title>: This is the title tag and it defines the title of the page.
- <body>: This is the body tag and it contains the actual content of the web page, such as text, images, links, and other elements.
Every HTML document must include the <html> tag, <head> tag, <title> tag, and <body> tag.
The <html> tag is the topmost element, and all the other tags are nested within this tag.
The <head> tag provides information about your HTML file; it is nested within the <html> tag. Typically, the <title> tag is the only tag nested within the <head> tag.
The <title> tag comes after the <head> tag. It should be included in every HTML document because it identifies the page to the rest of the world. Its output doesn't appear as part of the page but is displayed on the browser's title bar. If this tag is not coded, some browsers may show it as 'Untitled,' while others display the URL for the page on the browser's title bar.
The <body> tag complements the <head> tag and contains all the tags or elements that a browser displays as the body of your HTML document.
HTML is case-insensitive
The HTML code is not case-sensitive, meaning <html> and <HTML> are the same. Standard HTML code follows lowercase tags because it is recommended by the W3C (World Wide Web Consortium).