Structuring Content with Lists and Tables
Welcome Back! Let’s Get Organized
Hey there!
Welcome to Part 4 of our HTML series. By now, you’ve got a homepage that’s looking pretty good with text, images, and links. But what if you want to organize information in a more structured way? That’s where lists and tables come in!
What’s the Plan?
In this article, we’re going to explore how to use lists and tables to organize content on your webpage. Lists are great for displaying items in a clear, readable format, while tables are perfect for presenting data in rows and columns. Here’s what you’ll learn:
How to create ordered and unordered lists
Using nested lists for more complex structures
How to create a basic table
Adding headings, rows, and columns to your table
Styling your tables with simple borders
By the end of this article, you’ll have a better grasp of how to present your content in a way that’s both informative and easy on the eyes. Let’s dive in!
1. Creating Lists
Lists are incredibly useful for organizing content. Whether you’re making a list of your favorite movies, a to-do list, or a menu, HTML makes it easy.
Unordered Lists: Use an unordered list when the order of items doesn’t matter. These are typically displayed with bullet points.
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
Ordered Lists: Use an ordered list when the order of items does matter, like steps in a recipe. These are displayed with numbers.
<ol>
<li>Preheat the oven to 350°F.</li>
<li>Mix the ingredients.</li>
<li>Bake for 30 minutes.</li>
</ol>
Let’s add a list to your homepage. Maybe a list of the skills you’re learning:
<section>
<div>
<h2>Skills I'm Learning</h2>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</div>
</section>
2. Using Nested Lists
Sometimes you need a list within a list—for example, if you want to break down a task into subtasks. HTML supports nested lists, where you can place one list inside another.
<ul>
<li>Frontend Development
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
<li>Backend Development
<ul>
<li>Python</li>
<li>Django</li>
</ul>
</li>
</ul>
You can add a nested list to your homepage like this:
<section>
<div>
<h2>Skills I'm Learning</h2>
<ul>
<li>Frontend Development
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
<li>Backend Development
<ul>
<li>Python</li>
<li>Django</li>
</ul>
</li>
</ul>
</div>
</section>
3. Creating Tables
Tables are perfect for displaying data in a grid format. You can use tables to present schedules, pricing plans, or any kind of structured information.
Basic Table Structure: A basic table in HTML consists of the <table>
, <tr>
, <th>
, and <td>
tags.
<table>
: This element defines the table.<tr>
: This stands for "table row" and is used to define a row in the table.<th>
: This stands for "table header" and is used to define a header cell.<td>
: This stands for "table data" and is used to define a cell that contains data.
Here’s a simple example:
<table>
<tr>
<th>Day</th>
<th>Task</th>
</tr>
<tr>
<td>Monday</td>
<td>Learn HTML</td>
</tr>
<tr>
<td>Tuesday</td>
<td>Practice CSS</td>
</tr>
</table>
Let’s add a table to your homepage. Maybe a schedule of what you’re learning:
<section>
<div>
<h2>Learning Schedule</h2>
<table>
<tr>
<th>Day</th>
<th>Task</th>
</tr>
<tr>
<td>Monday</td>
<td>Learn HTML</td>
</tr>
<tr>
<td>Tuesday</td>
<td>Practice CSS</td>
</tr>
<tr>
<td>Wednesday</td>
<td>JavaScript Basics</td>
</tr>
</table>
</div>
</section>
4. Styling Your Tables
Tables can look a bit plain without some basic styling. While we’ll get more into CSS in future articles, here’s how you can add simple borders to your table:
<table border="1">
<tr>
<th>Day</th>
<th>Task</th>
</tr>
<tr>
<td>Monday</td>
<td>Learn HTML</td>
</tr>
<tr>
<td>Tuesday</td>
<td>Practice CSS</td>
</tr>
</table>
Adding the border="1"
attribute will give your table a basic border. This makes it easier to distinguish between the cells and rows.
What’s Next?
Nicely done! You’ve just learned how to organize your content using lists and tables, making your homepage even more informative and user-friendly. In the next article, we’ll start diving into styling with CSS, where you’ll learn how to make your site look beautiful.
So, keep up the momentum, and I’ll see you in the next article!
Subscribe to my newsletter
Read articles from Shivay Dwivedi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by