Styling the Guide Page
Introduction: The Role of CSS in Our Cooking Guide
Welcome back! So far, you have built a step-by-step cooking guide page using Flask and made it interactive with JavaScript. Now, it’s time to make your guide look polished and user-friendly. This is where CSS (Cascading Style Sheets) comes in.
CSS is the language used to style web pages. It controls how your HTML elements look — things like colors, spacing, fonts, and layout. Good styling makes your page easier to read and more enjoyable to use. In this lesson, you will learn how to use and adjust the provided CSS to improve your cooking guide.
By the end of this lesson, you will know how to:
- Understand what each part of the provided CSS does.
- Make simple changes to the look and feel of your guide page.
- Recognize how CSS helps users navigate and enjoy your site.
Let’s get started!
Quick Recap: Where CSS Fits In
Before we dive into the details, let’s quickly remind ourselves how CSS fits into your Flask project.
In your Flask app, you have an HTML template for the cooking guide. In a previous lesson, you learned how to link a CSS file to your HTML using a line like this in your template:
This line tells the browser to load the guide.css file from your static/css folder. Any styles defined in this file will be applied to your HTML elements.
Exploring the Provided CSS
Let’s look at the main parts of the guide.css file and see what each section does. We’ll go step by step, focusing on one idea at a time.
1. Styling the Main Container
The first class you’ll see is .guide-container. Here’s how it looks:
max-width: 600px;keeps the content from stretching too wide, making it easier to read.margin: 0 auto;centers the container on the page.padding: 1rem;adds space inside the container so the content doesn’t touch the edges.
2. Headings
Next, the h1 selector:
- This adds space below the main heading, so it doesn’t stick to the next element.
