Park Mains High School Coding Club

Lesson 2: ๐Ÿ“ Headings and paragraphs

By the end of this session, you will be able to:

Recap from Week 1

Last week you created your first webpage! You learned about:

Today, weโ€™re going to expand that page with more headings and paragraphs.

Step 1: Headings

Headings are like titles or chapter names. They range from <h1> (the biggest) to <h6> (the smallest).

Example:

<h1>My Cool Website</h1>
<h2>About Me</h2>
<h3>My Hobbies</h3>

What do I use headings for?

Headings are not just for making text bigger. They help browsers, search engines, and screen readers understand the structure of your page by organising information into sections and topics. This makes webpages easier for people to read and understand.

A webpage should usually have one main heading (<h1>) and smaller headings underneath it. For example, this webpage has:

Step 2: Paragraphs

Paragraphs hold the main text for your webpage. They are wrapped in <p> tags. You can have paragraph text outside of a <p> tag, but HTML tags donโ€™t just change how things look. They also tell the browser what the content is.

For example:

Example:

<p>I love coding because I can create games and websites.</p>
<p>My favourite subject at school is science.</p>

Step 3: Lists

When you have a lot of information on your page, it can be helpful to break it up using a list.

Lists can be ordered, like this:

  1. this is item one
  2. this is item two
  3. this is item three

or unordered, like this:

Lists are different to paragraphs because you need an opening and closing tag for the list, and also for each list item.

Create a list like this:

<p>My hobbies are</p>

<ul>
<li>Snowboarding</li>
<li>Software development</li>
<li>Computer games
<ul>
<li>Minecraft</li>
<li>Runescape</li>
<li>GTA V</li>
</ul>
</li>
</ul>

use <ul> tags for an unordered list, or <ol> for an ordered list.

Challenge

Copy this code into your webpage. Can you fix this broken list?

<p>My hobbies are:</p>
<ul>
<li>Snowboarding</li>

<li>Software development
<ul>
<li>Websites</li>
<li>Games</li>
<ol>
<li>Unity projects</li>
<li>Java apps</li>
</ul>
</li>

<li>Computer games
<ul>
<li>Minecraft
<li>Runescape</li>
<ul>
<li>PvM</li>
<li>Skilling</li>
</ol>
</li>
</ul>
</li>

<li>Reading books</li>

<ul>
<li>Fantasy</li>
<li>Science fiction</li>
</li>

<li>Badminton</li>
<li>Table tennis</li>
</ul>

Step 4: Comments

Developers often leave comments on their work to explain to themselves and others what a line or block of code does. These comments are ignored by the computer and only visible inside the code.

HTML offers the ability to add comments as well. A HTML comment looks like this:

<!-- This is a comment --> <p>This is visible content</p>

Browsers will ignore HTML comments and won't display them on the page.

IMPORTANT: Comments are still visible to users with CTRL+U or Inspect Element. Do not use them to store sensitive information.

Challenge

There is a hidden comment somewhere on this page. Use CTRL+U or Inspect Element to find it. What does it say?

Step 5: Why structure matters

Click here to view a version of this page with no structure.

What makes that page hard to read? It contains all of the same information as in this lesson, just with minimal HTML. Do you think it is easier or harder to follow?

Good developers write code which is easy to read and understand. Using headings, paragraphs, and lists not only helps your users, but helps you to maintain your webpage, by easily finding and changing information on it.

Step 6: Try it yourself

Create a profile page with:

Extension Challenge

Create a webpage about:

Your page must include:

  1. multiple headings
  2. paragraphs
  3. ordered and unordered lists
Continue to lesson 3