Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

HTML & CSS IntroductionChapter 18. Creating Websites

Main (List) Page Development

Main (List) Page Development

Developing the Main (List) Page

When a website has many pages, there is a page with a list of contents linking to each content page. The main page can be the same as the home page. For HTML and CSS practice purposes, we'll create different pages to explain different CSS techniques.

The image below is the target design of the main page example. In this example, we utilize components prepared in the previous chapter. The list layout is implemented using Flex Box.

Main List Page UI example

In the practice section below, we'll explain how to implement the target design using the following steps.

  1. Add a background image
  2. Create a basic structure of the page with the following components
    • Top bar
    • Card (only one card component)
    • Back button (to the home page)
    • Footer
  3. Replicate the card component and complete the list design

Practice

Objective:
Create a list page with Flex Box

1. Create a new HTML file for the home page

  • Create a copy of the index.html file and change the name to main-page.html.
  • Change the <title> section to HTML & CSS Introduction Practice.
  • Also, delete the existing content of the <body> element that was created in the previous practice.
  • The code should look like the one below.
main-page.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--Google Font-->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
    <!--Custom CSS-->
    <link rel="stylesheet" href="css/practice.css">
    <link rel="stylesheet" href="css/component.css">
    <title>HTML & CSS Introduction Practice</title>
  </head>
  <body>

  </body>
</html>

2. Add a background image

To add a background image, we can use the technique explained in the previous chapter. For the main page, we use a green block wall image and add a translucent layer on top of it. You can choose a background image you like.

For this page, we use the <head> section of the HTML file to set CSS as the CSS code is only applicable to this page.

This is the code for implementing the background image with a translucent layer on top.

main-page.html
  <style>
    body{
      background: url(img/green-blocks.png) repeat center top/cover;
      height: 100vh;
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .bg-cover-layer{
      background-color:rgba(255,255,255,0.7);
      height: 100vh;
      margin: 0;
      padding: 0;
    }
  </style>
</head>
<body>
  <div class="bg-cover-layer">

  </div>
</body>

At this point, this web page has a background only with no content, like shown in the image below.

Main List Page background image example

Tips: Live Server

When you develop code, keep running Live Server so that you can check the output in your browser in real-time.

Enabling Live Server

2. Create a basic structure of the page with components

We are adding the following components in this step:

  • Top bar
  • Card (only one card component)
  • Back button (to the home page)
  • Footer

To implement these components, add the code below within the <div> element with the bg-cover-layer class. As these components are the ones we have already prepared in the previous chapter, you don't need to add new CSS code.

main-page.html
<!--Top bar-->
<div class="top-bar" style="text-align: center; background-color: transparent;">
  <a href="index.html" class="top-bar-icon">
    <img src="img/html5.png">
    <img src="img/css3.png">
  </a>
</div>
<!--End top bar-->
<div style="display: flex; flex-wrap: wrap; justify-content: center">
  <div class="card">
    <a href="chapter1.html">
      <div class="card-bg">
        <span class="card-overlay-text">1. Overview</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 1.</small><br><b> Overview of Website Development</b></div>
        <div class="card-icon"><img src="img/html5.png"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
</div>
<br>
<div style="display: flex; justify-content: center; padding: 50px;">
  <a href="index.html" class="btn-small">Back</a>
</div>
<!--footer-->
<footer style="height: 20px; background-color: transparent; position: initial;">
  <p>HTML & CSS Introduction</p>
</footer>
<!--End footer-->

At this point, the structure of this page is set but it only has one card, like in the image below.

Main List Page UI interim example

At this point, we haven't created a page for chapter 1. The link set on the card doesn't work. We'll make it work in the next chapter.

3. Replicate the card component and complete the list design

This step requires meticulous repetitive work. Copy the card component, and replicate it for Chapter 2 to Chapter 19 with some adjustments.

Adjust the following part for each chapter card:

  • Link path (the href attribute part)
  • Card overlay text (use a short name for each chapter)
  • Card title text (chapter number and title)
  • Image icons (to indicate HTML and CSS topic coverage)

The code below is the complete set of code for the card component section. As the code is long, you can copy and paste it into your HTML document.

main-page.html
<div style="display: flex; flex-wrap: wrap; justify-content: center">
  <div class="card">
    <a href="chapter1.html">
      <div class="card-bg">
        <span class="card-overlay-text">1. Overview</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 1.</small><br><b> Overview of Website Development</b></div>
        <div class="card-icon"><img src="img/html5.png"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter2.html">
      <div class="card-bg">
        <span class="card-overlay-text">2. Coding Preparation</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 2.</small><br><b> Preparing for Website Coding</b></div>
        <div class="card-icon"><img src="img/html5.png"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter3.html">
      <div class="card-bg">
        <span class="card-overlay-text">3. HTML Basics</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 3.</small><br><b> HTML Basics</b></div>
        <div class="card-icon"><img src="img/html5.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter4.html">
      <div class="card-bg">
        <span class="card-overlay-text">4. Links & Images</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 4.</small><br><b> HTML: Add Links and Images</b></div>
        <div class="card-icon"><img src="img/html5.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter5.html">
      <div class="card-bg">
        <span class="card-overlay-text">5. Lists & Tables</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 5.</small><br><b> HTML: Create Lists and Tables</b></div>
        <div class="card-icon"><img src="img/html5.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter6.html">
      <div class="card-bg">
        <span class="card-overlay-text">6. Forms</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 6.</small><br><b> HTML: Create Forms</b></div>
        <div class="card-icon"><img src="img/html5.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter7.html">
      <div class="card-bg">
        <span class="card-overlay-text">7. HTML to CSS</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 7.</small><br><b> Bridging HTML and CSS</b></div>
        <div class="card-icon"><img src="img/html5.png"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter8.html">
      <div class="card-bg">
        <span class="card-overlay-text">8. CSS Basics</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 8.</small><br><b> CSS Basics</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter9.html">
      <div class="card-bg">
        <span class="card-overlay-text">9. Web Design</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 9.</small><br><b> Web Design Basics</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter10.html">
      <div class="card-bg">
        <span class="card-overlay-text">10. Sizing & Spacing</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 10.</small><br><b> CSS: Sizing and Spacing</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter11.html">
      <div class="card-bg">
        <span class="card-overlay-text">11. Styling Text & Image</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 11.</small><br><b> CSS: Styling Text and Images</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter12.html">
      <div class="card-bg">
        <span class="card-overlay-text">12. Styling Backgrounds</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 12.</small><br><b> CSS: Styling Backgrounds</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter13.html">
      <div class="card-bg">
        <span class="card-overlay-text">13. Styling Borders</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 13.</small><br><b> CSS: Styling Borders and Drawing Lines</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter14.html">
      <div class="card-bg">
        <span class="card-overlay-text">14. Layout</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 14.</small><br><b> CSS: Layout – Key Concepts and Display Property</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter15.html">
      <div class="card-bg">
        <span class="card-overlay-text">15. Flex Box</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 15.</small><br><b> CSS: Layout – Flex Box</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter16.html">
      <div class="card-bg">
        <span class="card-overlay-text">16. Styling Lists</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 16.</small><br><b> CSS: Styling Lists</b></div>
        <div class="card-icon"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter17.html">
      <div class="card-bg">
        <span class="card-overlay-text">17. Styling Components</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 17.</small><br><b> CSS: Styling Components</b></div>
        <div class="card-icon"><img src="img/html5.png"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter18.html">
      <div class="card-bg">
        <span class="card-overlay-text">18. Create Websites</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 18.</small><br><b> Creating Websites</b></div>
        <div class="card-icon"><img src="img/html5.png"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
  <div class="card">
    <a href="chapter19.html">
      <div class="card-bg">
        <span class="card-overlay-text">19. Publishing</span>
      </div>
      <div class="card-body">
        <div class="card-title"><small>Chapter 19.</small><br><b> Publishing Websites</b></div>
        <div class="card-icon"><img src="img/html5.png"><img src="img/css3.png"></div>
      </div>
    </a>
  </div>
</div>

Also, make a small adjustment in the CSS code for the card-overlay-text class. As the card designed in the previous chapter had only one line of text, the text position looked okay. But when we use multiple lines, the text positions are not well aligned. To fix this, add text-align: center to the card-overlay-text class.

component.css
.card-overlay-text{
  :
  text-align: center;
}

4. Check the result with a browser using Live Server

If you are running Live Server, check your browser. You can see that the target design has been implemented.
If you are not running Live Server, click on the Go Live button at the bottom of VS Code. Your browser will open the home page.

You can also check the sample result here (Demo Site).

link


You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Applying Background Images in CSS

background-image

CSS Filter Blur, Drop-Shadow, Brightness, Grayscale, and More

CSS Filter Blur, Drop-Shadow, Brightness, Grayscale, and More

Exploring Components and Layout in HTML & CSS

Components and Layout

Inserting Icons in HTML Code with AI Prompt

Inserting Icons in HTML Code with AI Prompt

Resolving Style Conflicts with CSS Specificity

Specificity

Applying Background Images in CSS

background-image

CSS Filter Blur, Drop-Shadow, Brightness, Grayscale, and More

CSS Filter Blur, Drop-Shadow, Brightness, Grayscale, and More

Exploring Components and Layout in HTML & CSS

Components and Layout

Inserting Icons in HTML Code with AI Prompt

Inserting Icons in HTML Code with AI Prompt

Resolving Style Conflicts with CSS Specificity

Specificity

Tags:

Button

Card

Top Bar

Footer

List Page

HTML & CSS Introduction
Course Content

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;