Skip to content
Qyubie Learn
Web Development courseLesson 2 of 20 · tap to see all lessons

Web Development · Beginner

HTML Fundamentals: Document Structure, Text, Links, Images, Lists, Tables, Forms, and Semantics

Write well-structured HTML: the document skeleton, headings and paragraphs, links, images, lists, tables, forms, and semantic elements, with live previews.

  • Qyubie Learn Editorial Team
  • Published
  • 14 min read

Includes 2 exercises and 2 quick checks you can do right here.

HTML (HyperText Markup Language) describes the structure of a page: this is a heading, this is a paragraph, this is a link, this is a form. It doesn't decide how things look; that's CSS, in the next lesson. Every page on the Web, including pages built by PHP or React, reaches the browser as HTML, so this is the foundation for the whole course.

By the end of this lesson you will be able to:

  • write the structure of an HTML document,
  • use headings, paragraphs, links, images, and lists,
  • build tables and forms, and
  • choose semantic elements that describe what content is.

Every example with a Preview panel is live: edit the code and the page updates as you type.

Elements, tags, and attributes

HTML is made of elements. Most have an opening tag, content, and a closing tag:

  opening tag        content        closing tag
 ┌─────┴─────┐ ┌─────────┴─────────┐ ┌──┴──┐
 <a href="/about">About this school</a>
    └────┬─────┘
     attribute (name="value")
  • Tag names go in angle brackets; the closing tag adds a /.
  • Attributes add information inside the opening tag, as name="value".
  • Elements can be nested inside each other, but must close in reverse order: <p><strong>Hi</strong></p>, not <p><strong>Hi</p></strong>.
  • A few elements are void (empty) and have no closing tag: <img>, <br>, <input>, <meta>, <link>, <hr>.

The document structure

Every HTML file follows the same skeleton:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>CS Society | Home</title>
  </head>
  <body>
    <h1>Welcome to the CS Society</h1>
    <p>Everything visible on the page goes in the body.</p>
  </body>
</html>
PartPurpose
<!DOCTYPE html>tells the browser this is modern HTML
<html lang="en">the root element; lang helps screen readers and search engines
<head>information about the page, not shown in it
<meta charset="utf-8">so characters like ñ and ₱ display correctly
<meta name="viewport" ...>makes the page fit phone screens (needed for responsive design)
<title>the text on the browser tab and in search results
<body>everything visible

Save the file as index.html and open it in a browser. A server sends index.html when someone visits a folder without naming a file, which is why a site's home page uses that name.

Headings and paragraphs

Headings go from <h1> (most important) to <h6>. Use them as an outline of the page, not to make text big: one <h1> for the page's topic, <h2> for its sections, <h3> inside those.

Try it · HTML & CSS

Preview (index.html, updates as you type)
  • <strong> marks important text (bold by default) and <em> adds emphasis (italic by default).
  • <br> breaks a line inside a paragraph. Don't use it to add space between paragraphs; that's CSS's job.
  • <hr> is a thematic break between sections.
  • The browser ignores extra spaces and line breaks in your code: ten spaces show as one.

A link is an <a> (anchor) element; href says where it goes:

Try it · HTML & CSS

Preview (index.html, updates as you type)
  • An absolute URL includes the scheme and domain (https://...); use it for other sites.
  • A relative URL like about.html or images/logo.png is found relative to the current page; use it within your own site, so the links still work when the site moves to another domain.
  • Link text should say where the link goes. "Click here" tells a screen-reader user nothing.

Images

<img> shows a picture. It has no closing tag:

Try it · HTML & CSS

Preview (index.html, updates as you type)
  • src is the image's URL: relative (images/campus.jpg) or absolute.
  • alt describes the image for people who can't see it, and is shown if it fails to load. It's required for accessibility. For purely decorative images, use an empty alt="".
  • width and height let the browser reserve space before the image loads, so the page doesn't jump.

Use JPG for photos, PNG for graphics with sharp edges or transparency, SVG for logos and icons, and WebP for smaller files of either kind.

Lists

Try it · HTML & CSS

Preview (index.html, updates as you type)
  • <ul> is an unordered (bulleted) list, <ol> an ordered (numbered) list, and each item is an <li>.
  • A list can be nested inside an <li>.
  • <dl> is a description list of terms (<dt>) and their descriptions (<dd>).
  • Navigation menus are usually a <ul> of links, styled with CSS.

Quick check

Which of these is written correctly?

Tables

Tables are for tabular data: rows and columns of related values, like a class schedule or a grade sheet. (Don't use tables to lay out a page; CSS does that.)

Try it · HTML & CSS

Preview (index.html, updates as you type)
  • <tr> is a row; <th> is a header cell and <td> a data cell.
  • <thead> and <tbody> group the header and body rows; <caption> titles the table.
  • colspan="3" makes a cell span three columns; rowspan spans rows.
  • The <style> block adds borders; without CSS, tables have none. You'll learn CSS next lesson.

Forms

Forms are how users send data to a server: sign-ups, logins, searches, enrollment. In lesson 5 you'll process them with PHP; here you'll build them.

Try it · HTML & CSS

Preview (index.html, updates as you type)

The important attributes:

AttributeOnMeaning
action<form>the URL the data is sent to
method<form>get (data in the URL) or post (data in the request body)
nameinputsthe key the server receives; an input without a name is not sent
id + <label for>inputslinks the label to the input, so clicking the label focuses it and screen readers announce it
type<input>text, email, password, number, date, radio, checkbox, file, …
requiredinputsthe browser won't submit until it's filled in
valueoptions, radios, checkboxeswhat's sent when that choice is picked

When this form is submitted, the browser sends something like full_name=Juan+Dela+Cruz&email=juan%40example.com&year_level=3&track=web to /register. Try it: fill in the form and press Register. The preview has no server, so instead of sending the data, it shows exactly what the browser would send.

Radio buttons in the same group share one name, so only one can be chosen. Browser checks like required and type="email" help users, but anyone can skip them, so the server must always check the data again (lesson 5).

Quick check

A form has <input type="text" id="school">. The user types BISU and submits. What does the server receive for this field?

Semantic HTML

<div> and <span> are generic containers with no meaning (block-level and inline, respectively). Semantic elements say what their content is:

ElementUse for
<header>the top of the page or of a section: logo, title
<nav>the main navigation links
<main>the page's main content (once per page)
<section>a themed group of content, usually with a heading
<article>a self-contained piece: a blog post, a news item, a product card
<aside>related side content: a sidebar, a tip box
<footer>the bottom: copyright, contact, links
<figure> + <figcaption>an image or diagram with a caption

Try it · HTML & CSS

Preview (index.html, updates as you type)

The page looks the same as with <div>s, so why bother?

  • Accessibility: screen readers let users jump straight to the <nav> or <main>.
  • Search engines understand which part is the real content.
  • Readable code: </nav> is clearer than the fifth </div> in a row.

&copy; is a character entity: a code for a character. Use &lt; and &gt; to show < and > as text, and &amp; for &.

Try it: a profile page

Exercise · HTML & CSS

Student profile page

Build a semantic profile page: a <header> with an <h1> name, a <main> with a <section> that has an <h2> and a <ul> of at least two skills, an <img> with an alt text, and a <footer>.

Preview (index.html, updates as you type)
Hint

Wrap the name in <header><h1>…</h1></header>. Inside <main>, put a <section> with an <h2>, a <ul> with <li> items, and an <img src="/qyubie-mark.png" alt="…">. End with <footer>.

Show a solution

Try it yourself first — you learn more from a wrong attempt than from reading an answer.

<header>
  <h1>Ana Reyes</h1>
</header>

<main>
  <section>
    <h2>Skills</h2>
    <ul>
      <li>HTML and CSS</li>
      <li>Java</li>
      <li>Photo editing</li>
    </ul>
    <img src="/qyubie-mark.png" alt="My favorite logo" width="80">
  </section>
</main>

<footer>
  <p>Contact: ana@example.com</p>
</footer>

Exercise · HTML & CSS

Enrollment form

Make a form that posts to /enroll with: a labelled text input named student_no, a labelled <select> named course with at least two options, and a submit <button>. Link each label to its input with for and id.

Preview (index.html, updates as you type)
Hint

Pattern: <label for="sn">Student number</label> <input type="text" id="sn" name="student_no">. The select works the same way, with <option> elements inside.

Show a solution

Try it yourself first — you learn more from a wrong attempt than from reading an answer.

<form action="/enroll" method="post">
  <p>
    <label for="sn">Student number</label><br>
    <input type="text" id="sn" name="student_no" required>
  </p>
  <p>
    <label for="course">Course</label><br>
    <select id="course" name="course">
      <option value="BSCS">BS Computer Science</option>
      <option value="BSIT">BS Information Technology</option>
    </select>
  </p>
  <button type="submit">Enroll</button>
</form>

Common mistakes

  • Closing tags in the wrong order, or forgetting them.
  • Using headings for size (an <h4> because it "looks right"). Use headings for structure and CSS for size.
  • Missing alt on images, or alt="image", which says nothing.
  • Inputs without name, so the server never receives them.
  • Labels not linked to inputs (for must match the input's id).
  • Tables for page layout, and <div> for everything when a semantic element fits.
  • Spaces in file names (my page.html). Use lowercase and hyphens: my-page.html.

Summary

  • An HTML document has a <!DOCTYPE html>, an <html> root, a <head> (title, meta) and a <body> (content).
  • Text: <h1>–<h6>, <p>, <strong>, <em>. Links: <a href>. Images: <img src alt>. Lists: <ul>, <ol>, <li>.
  • Tables use <table>, <tr>, <th>, <td>, with <thead> and <tbody>, for tabular data only.
  • Forms send data to action using method; each input's name becomes the key, and labels link to inputs by id.
  • Semantic elements (<header>, <nav>, <main>, <section>, <article>, <footer>) describe what content is.

For a shorter, guided start, try build your first web page.

Next lesson: CSS fundamentals: colors, fonts, the box model, layout, and responsive design.

References and further reading