🛠️

HTML Lecture Series by Dave Gray

Jul 15, 2024

HTML Lecture Series by Dave Gray

Introduction

  • Presenter: Dave Gray, HTML tutorial creator.
  • Series Length: Four hours (comprised of 10 tutorials).
  • Resources: Links mentioned in tutorials are compiled in a GitHub repository available in the description.
  • Collaborations: Thank you to Bo at FreeCodeCamp for sharing the video.
  • Social Media: Subscribe on YouTube, follow on Twitter, you can buy Dave a coffee if feeling generous.

Chapter 1: What is HTML?

  • HTML Definition: HTML stands for Hypertext Markup Language. Basic building block of the web, defines the meaning and structure of web content.
  • Hypertext: Refers to links connecting web pages.
  • Markup: Used to annotate text, images, and other content for display in a web browser.

Necessary Tools

  1. Web Browser: Recommended: Google Chrome (download at google.com/chrome).
  2. Code Editor: Recommended: Visual Studio Code (download at code.visualstudio.com).
  3. Extensions: Recommended for Chrome: Dark New Tab (search in Chrome Web Store).
  4. Icon Themes: VS Code Icons for file type visibility.
  5. Themes: GitHub Theme (personal preference for dark mode).
  6. Live Server: VS Code extension for running local server and viewing changes live.

Creating First HTML File

  • Folder Setup: Create a folder to store HTML course files. (e.g., HTML course > 01_lesson).
  • Creating Index File: Start with a blank file named index.html (lowercase, no spaces).
  • HTML Skeleton: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My First Web Page</title> </head> <body> <h1>Hello World</h1> <p>This is my first web page.</p> </body> </html>

Live Server & Setup

  1. Run Live Server: Open the index.html file and use “Open with Live Server” to see the changes in real-time in the browser.
  2. Dark Mode for Browser: Example CSS for saving eyes in development (optional).
<style> body { font-size: 20px; background-color: #333; color: whitesmoke; } </style>

Validating HTML

  • Validator: Use W3C Markup Validation Service (validator.w3.org) for checking HTML errors.
    • Character Encoding: Add meta tag in head. <meta charset="UTF-8">
    • Language Attribute: Add in the HTML tag. <html lang="en">
    • DOCTYPE Declaration: Ensure it’s at the very top. <!DOCTYPE html>
    - Validation Process: Upload the `index.html` file and ensure no errors or warnings.

Metadata and More Tags

  1. Meta Tags: Including name and author tags.
<meta name="author" content="Dave Gray"> <meta name="description" content="Learning HTML with Dave Gray">
  1. Favicons: Adding favicons in the head section.
<link rel="icon" href="HTML5.png" type="image/x-icon">
  1. External CSS: Moving inline style to an external stylesheet.
<link href="main.css" rel="stylesheet" type="text/css">

Text Content and Lists

Headings and Paragraphs

  • Usage: Headings (H1 to H6) to create a hierarchy and paragraphs for text.
  • Example: <h1>Main Title</h1> <h2>Sub Title</h2> <h3>Sub-sub Title</h3> <p>This is a paragraph.</p>

List Types

  1. Ordered Lists:
<ol> <li>First Item</li> <li>Second Item</li> </ol>
  1. Unordered Lists:
<ul> <li>First Item</li> <li>Second Item</li> </ul>
  1. Description Lists:
<dl> <dt>Term</dt> <dd>Description</dd> </dl>

Links and Multimedia

Creating Hyperlinks

  • Anchor Tags: Creating links with anchor <a> tags.
  • Absolute vs Relative URLs: <a href="https://example.com">External Link</a> <a href="/about">Internal Link</a>
  • Target Attribute: Open in new tab. <a href="https://example.com" target="_blank">Open in new tab</a>

Adding Images

  • Image Element: <img src="image.jpg" alt="Description" width="300" height="200">
  • Figure and Figcaption: For grouped images with captions. <figure> <img src="image.jpg" alt="Description"> <figcaption>Caption for the image.</figcaption> </figure>

Semantic HTML

Semantic Layout Elements

  • Header, Main, Footer: <header>Header Content</header> <main>Main Content</main> <footer>Footer Content</footer>
  • Nav and Sections: Improve accessibility and document navigation. <nav>Navigation Links</nav> <section>Section Content</section>
  • Use of div and span for non-semantic grouping of elements (used sparingly).

Tables

Creating Tables

  • Basic Structure: <table> <caption>Table Caption</caption> <thead> <tr><th>Header</th><th>Header</th></tr> </thead> <tbody> <tr><td>Data</td><td>Data</td></tr> </tbody> <tfoot> <tr><td colspan="2">Footer</td></tr> </tfoot> </table>
  • Attributes:
    • scope for headers (col or row).
    • colspan and rowspan for spanning multiple cells.

Forms

Creating Forms

  • Form Element: Attributes for action and method. <form action="/submit" method="post">
  • Input Types and Labels: Text, password, radio, checkbox, submit, and more. <label for="name">Name:</label><input type="text" id="name" name="name">
  • Fieldsets and Legends: Grouping form elements. <fieldset> <legend>Group Name</legend> </fieldset>

HTML Project: Little Taco Shop Website

  • Creating Pages: Index.html, hours.html, contact.html.
  • Header and Footer Elements: Consistent across all pages.
  • Navigation Links: Internal and external.
  • Content:
    • Index Page: Welcome message, about section, menu in a table.
    • Hours Page: Store hours listed in a description list.
    • Contact Page: Contact form with various input types, address information.

Important Tips

  1. Validation: Always validate your HTML to catch errors early.
  2. HTML Entities: Use for special characters (e.g., &nbsp; for space, &copy; for copyright).
  3. Accessibility: Use appropriate tags and attributes to improve accessibility (e.g., alt for images, label for form inputs).
  4. Semantics: Ensure your HTML conveys meaning to improve SEO and accessibility.

Conclusion

  • Practice: Build projects to solidify what you learn.
  • Resources: Utilize tools and resources like validators, MDN, and tutorials to keep improving your skills.