HTML

HTML (HyperText Markup Language) is the standard markup language used to create web pages. It structures the content of a page, including titles, paragraphs, images, links, lists, and other essential elements of a webpage. HTML is the backbone of all websites, and it is often combined with other technologies like CSS (Cascading Style Sheets) for styling and JavaScript for interactivity.

HTML uses tags to define various elements of a page. These tags are typically enclosed in angle brackets (e.g., <p> for a paragraph, <a> for a link) and can contain attributes that provide additional information about the element. For example, the <img> tag used to insert an image may have a src attribute to specify the path to the image file.

Basic Structure of an HTML Page

A typical HTML page starts with a document type declaration (DOCTYPE) indicating which version of HTML is used. It then contains two main sections: the head and the body.

  1. DOCTYPE and <html> Element:
    • The <!DOCTYPE html> declaration at the beginning of the file indicates that the page uses HTML5, the latest version of HTML.
    • The <html> element wraps all the content of the page.
  2. Head (<head>):
    • The <head> section contains metadata that is not displayed on the page itself but is essential for the browser or search engines. For example, the title of the page is defined with the <title> tag, and external files like CSS stylesheets or JavaScript scripts are linked with the <link> and <script> tags.
  3. Body (<body>):
    • The <body> section contains the visible content of the page, such as text, images, videos, and links. Common elements in this section include:
      • <h1> to <h6> for headings (from level 1 to level 6),
      • <p> for paragraphs,
      • <a> for hyperlinks,
      • <img> for images,
      • <ul>, <ol>, and <li> for unordered, ordered lists, and list items.

Example of a Simple HTML Page

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example HTML Page</title>
</head>
<body>
    <header>
        <h1>Welcome to my website</h1>
    </header>
    <section>
        <p>This is an example of a simple HTML page. <a href="https://www.example.com">Click here</a> to visit another site.</p>
        <img src="image.jpg" alt="Example image">
    </section>
</body>
</html>

HTML Attributes

Attributes are used within HTML tags to provide additional information. For example:

  • src: specifies the path to a file (e.g., an image or video),
  • href: used in the <a> tag to define a link’s URL,
  • alt: provides an alternative description for an image (important for accessibility),
  • id: uniquely identifies an element on the page (used for CSS styling and JavaScript interaction),
  • class: assigns one or more classes to an element for applying CSS styles.

Conclusion

HTML is a fundamental language for creating web pages. It allows you to structure content logically and add interactive elements. Even though it is often used alongside other technologies like CSS and JavaScript, understanding the basics of HTML is essential for any web developer. It helps in designing accessible, well-structured, and maintainable web pages.

Catégories d’articles