intro-frontend-course

Introduction to HTML

HTML, which stands for HyperText Markup Language, is the standard markup language used to create and structure web pages. It provides the basic building blocks for creating a website, including headings, paragraphs, links, images, and more. Understanding HTML is essential for anyone looking to get started in frontend development.

In this lesson, we will cover the fundamentals of HTML, including the syntax and structure of HTML elements, how to create a basic HTML document, and the importance of semantic HTML. You will also learn about common HTML tags and how to use them to create well-structured and accessible web content.

By the end of this lesson, you will have a solid understanding of HTML and be ready to dive deeper into frontend development. HTML is the foundation of web development, and mastering it will pave the way for you to create beautiful and functional websites.

Key Lesson Concepts

HTML Documents

HTML documents are composed using a series of elements known as “tags” which serve to define various content types. Each HTML file must end with the .html extension, such as index.html.

When a browser loads an HTML file, it reads and interprets the file to construct something called the Document Object Model (DOM). The DOM represents the hierarchical structure of the document in a tree-like format, consisting of various nodes, including elements and text nodes. This model allows browsers to render the visual layout of the web page efficiently.

Through the use of tags and their attributes, HTML provides a robust framework to embed images, text, videos, and other multimedia files, creating rich, interactive experiences on the internet.

See the Pen Untitled by Mik M (@Mik-M) on CodePen.

Basic HTML Page Structure

When the browser sees the above code, it converts it into a tree-like DOM structure as follows:

Document
└── html
    ├── head
    │   └── title
    │       └── "Sample Web Page"
    └── body
        ├── h1
        │   └── "Welcome to My Web Page"
        └── p
            ├── "This is a paragraph with a link to "
            ├── a
            │   └── "Example.com"
            └── "."

All the elements on the tree, including the text, are also referred to as “nodes”.

HTML Elements Overview

1. Text Formatting Elements

2. List Elements

See the Pen Untitled by Mik M (@Mik-M) on CodePen.

3. Linking and Images:

See the Pen Untitled by Mik M (@Mik-M) on CodePen.

4. Tables for Organizing Data:

See the Pen table example by Mik M (@Mik-M) on CodePen.

5. Forms for Input:

See the Pen form-exmaple by Mik M (@Mik-M) on CodePen.

More on forms…

Form Tag (<form>): Defines an HTML form for user input:

<form action="/submit-form" method="post">
  <!-- Form contents go here -->
</form>

Input Tag (<input>): Used for creating interactive controls for web-based forms to collect user data:

<form action="/submit-form" method="post">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name"><br><br>
  
  <label for="email">Email:</label>
  <input type="email" id="email" name="email"><br><br>
</form>

Label Tag (<label>): Specifies a label for an <input> element, improving accessibility by linking the text label to the input control:

<form action="/submit-form" method="post">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username"><br><br>
  
  <label for="password">Password:</label>
  <input type="password" id="password" name="password"><br><br>
</form>

Textarea Tag (<textarea>): Used for multi-line text input:

<form action="/submit-form" method="post">
  <label for="message">Message:</label><br>
  <textarea id="message" name="message" rows="4" cols="50"></textarea><br><br>
</form>

Select Tag (<select>): Used to create a drop-down list:

<form action="/submit-form" method="post">
  <label for="options">Choose an option:</label>
  <select id="options" name="options">
    <option value="option1">Option 1</option>
    <option value="option2">Option 2</option>
    <option value="option3">Option 3</option>
  </select><br><br>
</form>

Option Tag (<option>): Used within the

<form action="/submit-form" method="post">
  <label for="fruit">Choose a fruit:</label>
  <select id="fruit" name="fruit">
    <option value="apple">Apple</option>
    <option value="banana">Banana</option>
    <option value="cherry">Cherry</option>
  </select><br><br>
</form>

Submit Button (<input type="submit">): Button that submits the form to a server:

<form action="/submit-form" method="post">
  <label for="fname">First Name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  
  <label for="lname">Last Name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  
  <input type="submit" value="Submit">
</form>

Complete form example:

See the Pen Untitled by Mik M (@Mik-M) on CodePen.

Semantic HTML for Accessibility

Semantic elements such as

provide clear information about the role of the content hold, helping both search engines and assistive technologies to interpret page content correctly.

Example of a Structured HTML Page

Combining these elements, a structured HTML page might look like this:

See the Pen code-example block by Mik M (@Mik-M) on CodePen.

Best Practices for Writing HTML

Finally, by understanding these fundamentals, you are prepared to dive deeper into more complex HTML structures and dynamic content management. This comprehensive approach ensures you are equipped with the knowledge to start building accessible and well-structured web pages.

For more in-depth introdution to HTML and guides, check out this video: