Ad Code

Responsive Advertisement

html coding - Part 4 - HTML Document Structure

 HTML Document Structure

An HTML document is made up of several key elements that provide structure and organization to the content.
The Basic Structure
HTML
<!DOCTYPE html>
<html>
<head>
	<title>Page Title</title>
</head>
<body>
	<!-- Content goes here -->
</body>
</html>
Elements of the HTML Document Structure
  1. <!DOCTYPE html>: Declares the document type and version.
  2. <html>: The root element of the document.
  3. <head>: Contains metadata about the document.
  4. <title>: Sets the title of the page, displayed in the browser's title bar.
  5. <body>: Contains the content of the HTML document.
Other Important Elements
  1. <meta>: Provides additional metadata about the document, such as character encoding, author, and keywords.
  2. <link>: Links to external stylesheets or other resources.
  3. <script>: Adds JavaScript code to the document.
Example of a Complete HTML Document
HTML
<!DOCTYPE html>
<html>
<head>
	<title>My Web Page</title>
	<meta charset="UTF-8">
	<link rel="stylesheet" href="styles.css">
</head>
<body>
	<h1>Welcome to My Web Page</h1>
	<p>This is a paragraph of text.</p>
	<script src="script.js"></script>
</body>
</html>
Best Practices
  • Use a consistent indentation scheme to make your code readable.
  • Use comments (<!-- -->) to explain your code and leave notes.
  • Use a <!DOCTYPE html> declaration to ensure compatibility with modern browsers.

Post a Comment

0 Comments


Ad Code

Responsive Advertisement