Making Lists (and Pizza!πŸ•) with HTML & CSS:

Samir ShumanSamir Shuman
7 min read

Hey pizza lovers and web developers! πŸ‘‹ Remember my extra cheesy posts about text gradients and React Three Fiber? Well, today we're diving into something equally as delicious, HTML lists! And because pizza makes everything better (and you know I can't write a post without mentioning it πŸ˜‰), we're going to learn by creating an amazing gluten-free, low-carb pizza recipe that'll make both your stomach and your code editor happy. Whether you're following a keto diet or just looking to cut down on carbs, this recipe is a game-changer!

A Slice of Semantic HTML πŸ€“

Before we dive into our recipe, let's talk about semantic HTML for a hot second. You know how a pizza has distinct layers - the crust, sauce, and toppings? Well, semantic HTML is kind of like that. Instead of just throwing everything into <div> tags (which would be like putting all your toppings in a blender... yuck! 🀒), we use specific tags that actually describe what our content is.

<!-- Not semantic (the pizza blender approach) -->
<div class="recipe">
    <div class="recipe-title">Low-Carb Pizza</div>
    <div class="recipe-list">...</div>
</div>

<!-- Semantic (the properly layered pizza approach) -->
<article class="recipe">
    <h1>Low-Carb Pizza</h1>
    <section class="ingredients">...</section>
</article>

We've got awesome semantic tags like <article>, <section>, <nav>, <header>, <footer>, and even <aside> (for those side orders of garlic knots, obviously πŸ˜‰). But you know what's missing? <pizza>! I mean, seriously W3C, how is this not a standard HTML element yet?

<!-- In my dreams... -->
<pizza>
    <crust>Low-carb mozzarella</crust>
    <sauce>Crushed tomatoes</sauce>
    <toppings>
        <topping>More mozzarella</topping>
        <!-- Because there's no such thing as too much cheese -->
    </toppings>
</pizza>

Until my petition for pizza-semantic-tags gets approved (don't hold your breath πŸ˜‚), we'll stick with the current semantic elements for our recipe. They help screen readers understand our content better, improve SEO, and keep our code as organized as a well-managed pizzeria!

Why Lists? πŸ€”

Lists are everywhere on the web - navigation menus, recipe ingredients, step-by-step tutorials (like this one!), and pretty much anywhere you need to organize information. But here's the thing: they're not just about slapping some bullet points on your content. With the right HTML structure and some CSS magic, you can create lists that are both functional and fabulous!

The Basic Ingredients πŸ“

Just like our pizza recipe needs specific ingredients, HTML lists come with their own essential elements. Let's break them down:

<!-- Unordered list (ul) - for ingredients -->
<ul>
    <li>Item 1</li>
    <li>Item 2</li>
</ul>

<!-- Ordered list (ol) - for steps -->
<ol>
    <li>Step 1</li>
    <li>Step 2</li>
</ol>

Think of <ul> as your pizza toppings (they can go in any order) and <ol> as your recipe steps (order matters!). The <li> elements are like your individual ingredients - they're what make up the list.

Let's Make Some Pizza! πŸ•

Now, let's put these lists to work with our actual recipe. First, our ingredients:

<div class="recipe-card">
         <h2>πŸ• Low-Carb
            <span class="image-text">P</span> /*see my post on text-gradients and text background images to learn how to apply this effect*/
            <span class="image-text">I</span>
            <span class="image-text">Z</span>
            <span class="image-text">Z</span>
            <span class="image-text">A</span>
            Recipe πŸ•
        </h2>

        <div class="section">
            <h3>Ingredients</h3>
            <ul class="ingredients-list">
                <li> 4 cups low moisture mozzarella cheese
                    <ul>
                        <li>2Β½ cups mozzarella cheese (for crust)
                        </li>
                        <li>1Β½ cups mozzarella cheese (for topping)</li>
                    </ul>
                </li>
                <li>2 oz cream cheese</li>
                <li>1 egg</li>
                <li>Β½ tablespoon baking powder</li>
                <li>Β½ teaspoon xanthan gum</li>
                <li>1 teaspoon Italian seasoning</li>
                <li>1 teaspoon garlic powder</li>

                <li>3/4 cup crushed tomatoes</li>
                <li>2 tablespoons olive oil</li>
            </ul>
        </div>

        <div class="section">
            <h3>Equipment Needed</h3>
            <ul class="equipment-list">
                <li>Heavy bottom pan</li>
                <li>Parchment paper</li>
                <li>Microwave-safe bowl</li>
            </ul>
        </div>

Let's style our lists with some pizzazz! 🎨

h2, h3 {
    color: #2d3748;
    margin: 1.5rem 0 1rem;
    text-align: center;
}

h2 {
    font-size: 2rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.section {
    background-color: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
.recipe-card {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: #fff;
}

.ingredients-list li {
    padding: 0.5rem 0;
    padding-left: 2rem;
    position: relative;
    transition: transform 0.2s ease;  /* Smooth hover effect */
}

.ingredients-list li:hover {
    transform: translateX(10px);  /* Slide effect on hover */
}

Want to make your lists more appetizing? Instead of boring bullet points, you can use any emoji as a list marker! First, remove the default bullets with list-style: none, then use the ::before pseudo-element to add your custom marker. The content property is where the magic happens - you can use a pizza emoji (or any other emoji) to spice up your lists. Just make sure to add a bit of margin to keep things nicely spaced out!

.ingredients-list {
 list-style: none; /* Remove default bullets */
}

.ingredients-list li::before {
 content: "πŸ•"; /* Pizza emoji as marker */
 margin-right: 8px; /* Space between emoji and text */
 display: inline-block;
}

Now for the complete cooking instructions. Check out how we can style ordered lists differently:

<ol class="instructions">
    <li>Preheat oven to 375Β°F (190Β°C)</li>
    <li>Combine 2Β½ cups mozzarella with cream cheese in a microwave-safe bowl</li>
    <li>Heat in 30-second intervals, stirring between each interval, until fully melted</li>
    <li>Add all dry ingredients and mix until fully incorporated</li>
    <li>Mix in the egg</li>
    <li>Oil two 18x18 pieces of parchment paper</li>
    <li>Place dough ball between the oiled parchment papers</li>
    <li>Use a rolling pin to roll dough as round and thin as possible</li>
    <li>Roll edges up to form crust shape</li>
    <li>Place in preheated pan with parchment paper under the crust</li>
    <li>Bake for 12 minutes or until slightly browned</li>
    <li>Remove from oven and add crushed tomatoes and cheese</li>
    <li>Increase oven temperature to 400Β°F (200Β°C)</li>
    <li>Bake for additional 10-12 minutes until cheese is melted and bubbling</li>
    <li>Let rest for 5 minutes before cutting</li>
</ol>

.instructions {
    counter-reset: step;  /* Creates custom counter */
    list-style: none;
    padding-left: 0;
}

.instructions li {
    position: relative;
    padding: 1rem 0 1rem 3rem;
    margin-bottom: 0.5rem;
}

.instructions li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    background: #ff6b6b;  /* Pizza sauce red! */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

You can absolutely omit the CSS styling, including the pseudo-elements like ::before and counters, and your ordered and unordered lists will still function perfectly. The HTML provides the structure and content of the lists, while the CSS simply enhances their visual appearance.

Pro Tips! πŸ”₯

Let's use a nested list to share some important notes about our pizza:

<ul class="pro-tips">
    <li>Reheating instructions:
        <ul>
            <li>Reheat in oven at 400Β°F (200Β°C) for 10-12 minutes</li>
            <li>Do NOT use microwave - trust me on this one! πŸ™…β€β™‚οΈ</li>
        </ul>
    </li>
    <li>Customization options:
        <ul>
            <li>Try different cheese blends for the topping</li>
            <li>Add your favorite low-carb toppings</li>
            <li>Experiment with different herbs in the crust</li>
        </ul>
    </li>
</ul>

.pro-tips {
    background-color: #fffaf0;
    border-left: 4px solid #ed8936;
    padding: 1.5rem;
    margin-top: 2rem;
    border-radius: 8px;
}

.pro-tips > li {
    list-style: none;
    margin-bottom: 1rem;
    font-weight: bold;
}

.pro-tips ul {
    margin-top: 0.5rem;
    margin-left: 1.5rem;
    font-weight: normal;
}

.pro-tips ul li {
    margin: 0.5rem 0;
    list-style: disc;
}

Making It Mobile-Friendly πŸ“±

Just like our pizza needs to fit in different pans, our lists need to work on different screen sizes. Here's how to make them responsive:

@media (max-width: 768px) {
    .recipe-card {
        margin: 1rem;
        padding: 1rem;
    }

    .instructions li {
        padding-left: 2.5rem;  /* Smaller padding on mobile */
    }

    .instructions li::before {
        width: 1.5rem;  /* Smaller numbers on mobile */
        height: 1.5rem;
        font-size: 0.9rem;
    }

    .pro-tips ul {
        padding-left: 1rem;  /* Less indentation for nested lists */
    }
}

Wrapping Up πŸŽ‰

And there you have it, folks! Not only do you now know how to create and style HTML lists like a pro, but you've also got a killer gluten-free, low-carb pizza recipe to try out. The best part? Just like how we can nest lists inside other lists, you can stack these pizza slices right into your meal prep routine!

Remember, whether you're coding or cooking, it's all about experimenting and finding what works best for you. Drop a comment below if you try either the HTML tricks or the pizza recipe - I'd love to hear how it turned out!

Until next timeβ€¦πŸ•πŸ˜ŽβœŒοΈ

P.S. Want more pizza-themed web dev tutorials? Hit me up on BlueSky, X/Twitter, or check out my other posts right here!

Don't forget to check out my previous post about text gradients and text background images - it pairs perfectly with these list styling techniques!

1
Subscribe to my newsletter

Read articles from Samir Shuman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Samir Shuman
Samir Shuman

Welcome to my blog! My name is Samir. I'm a full-stack software engineer specializing in web development. I'm based in the San Francisco Bay Area, but can deliver digital solutions globally. When I'm not coding, I love experimenting in the kitchen, watching basketball, and spending time with my cat, Fuzzy. Let's connect!