T E C h O C E A N H U B

HTML structure and syntax

HTML (Hypertext Markup Language) is the standard markup language used for creating the structure and presenting the content of web pages. It uses a set of tags and attributes to define the elements and their properties within a document. Here is an overview of HTML’s structure and syntax:

  1. Document Structure: An HTML document consists of several main components:
    • Document type declaration: <!DOCTYPE html>
    • HTML root element: <html>
    • Head section: <head>
    • Body section: <body>
  2. Head Section: The head section contains meta-information and external resources related to the web page. Some common elements found in the head section are:
    • Title: <title> specifies the title of the web page.
    • Metadata: <meta> elements provide additional information about the document (e.g., character encoding, description, keywords).
    • CSS: <link> or <style> elements are used to link or embed CSS stylesheets.
    • JavaScript: <script> elements can be used to include JavaScript code.
  3. Body Section: The body section contains the visible content of the web page. It consists of various HTML elements that define the structure and appearance of the content. Some commonly used elements include:
    • Headings: <h1> to <h6> define headings of different levels.
    • Paragraphs: <p> represents a paragraph of text.
    • Links: <a> creates hyperlinks to other web pages or resources.
    • Images: <img> embeds images into the page.
    • Lists: <ul>, <ol>, and <li> create unordered and ordered lists.
    • Tables: <table>, <tr>, <th>, and <td> define tabular data.
    • Forms: <form>, <input>, <select>, <textarea>, etc., are used for creating interactive forms.
    • Divisions: <div> is a generic container for grouping and styling content.
    • Span: <span> is an inline container used for styling smaller parts of text.
  4. HTML Tags: HTML tags are used to enclose content and define its meaning or behavior. Tags are written as opening and closing pairs or self-closing for void elements. Examples:
    • Opening and closing tag: <tagname>Content</tagname>
    • Self-closing tag: <tagname attribute="value" />
  5. Attributes: HTML elements can have attributes that provide additional information about the element or modify its behavior. Attributes are specified within the opening tag of an element. Examples:
    • <a href="https://www.example.com">Link</a>: “href” attribute specifies the URL the link points to.
    • <img src="image.jpg" alt="Description" />: “src” attribute defines the image source, and “alt” provides alternative text.

It’s important to note that HTML is not a programming language but a markup language used for structuring content. It defines the presentation and structure of the web page but lacks interactivity. For dynamic behavior and functionality, JavaScript is often used in conjunction with HTML.

Copyright ©TechOceanhub All Rights Reserved.