Browser Console

The example scripts can be found in Book 1 - Programming Step by Step and More.

Book 1 is for sale on Amazon

Exercise 8.1.1: Block Containers


Header Content

Main Content

Footer Content



In the script above, we applied styles to the div tags that enclose the entire page as the container, the header with the header content, the main section where the main topic is displayed, and the footer that contains the message at the bottom of the page.

Exercise 8.1.2: Semantic Section Containers:

Article Title
Article Content
Final notes or message at the bottom of the page

What is shown in Exercises 8.1.1 and 8.1.2 above is the common styling practice found in the structure of web page design.
A container that encloses the body with the article title, the main content, and the final notes or messages at the bottom of the page. In this container we define the margins, and the font sizes are left to be declared individually as needed in each section inside the container.

8.1.3: Flexbox Containers

Item 1
Item 2
Item 3

This type of container automatically adapts to different screen sizes, making the layout more responsive.

8.1.4: Grid Layout Containers

Item 1
Item 2
Item 3
Item 4

These styles help in creating complex layouts with rows and columns. Precision: Allows precise alignment of elements. Responsiveness: Makes it easier to create responsive designs that adapt to different screen sizes.

Exercise 5: Advanced Flexbox Style Examples

Navigation Menu

Flexbox Container: The .navbar class uses display: flex; to create a horizontal navigation bar.
Space Distribution: justify-content: space-around; distributes the elements evenly.
Alignment: align-items: center; centers the elements vertically.
Responsiveness: With a media query, the direction changes to flex-direction: column; on small screens, making the elements stack vertically.

Exercise 6: Advanced Grid Layout Style Examples

We will create an image gallery with a grid that automatically adjusts according to the screen size.

display: grid; is used to create a grid layout.
Column Definition: grid-template-columns: repeat(3, 1fr); creates three columns of equal width.
Spacing: grid-gap: 10px; adds space between elements.
Responsiveness: With media queries, the number of columns adjusts to two on medium screens and one on small screens.