HTML Basics

HTML documents are made up of elements and tags. An HTML element can be a simple tag or a tag with content inside of it. Each element tells the browser how to render content on a webpage.

HTML Elements

HTML elements are the building blocks of an HTML page. An element consists of an opening tag, content, and a closing tag.

HTML Attributes

HTML attributes provide additional information about HTML elements. Attributes are always written inside the opening tag of an element.

HTML Document Structure

Every HTML document follows a basic structure. Here’s an overview of how it looks:

  1. DOCTYPE declaration: Specifies the document type (e.g., <!DOCTYPE html>)
  2. HTML element: The root element that wraps all content (<html>)
  3. Head element: Contains meta-information like the character set, title, and link to stylesheets (<head>)
  4. Body element: Contains the content that appears on the webpage (<body>)
HTML Forms

Forms (<form>) are used to collect user input. A form can contain input fields (e.g., <text>, <checkbox>, <password>), labels, and submit buttons.

HTML Media Elements

HTML also allows you to embed media such as images (<img>), audio (<audio>), and video (<video>).

HTML Best Practices

Here are some best practices to follow when writing HTML:

  1. Use semantic elements: Elements like <header>, <footer>, <article>, and <section> provide meaning to your content and help with accessibility.
  2. Structure your code properly: Use indentation and spacing to make your HTML readable.
  3. Avoid inline styles: Instead, use external CSS for styling.