Mary Junnette M. Urtua BS Information Technology · 3F
  • Home
  • HTML ▾
    • 1. HTML Basics
    • 2. Text Exercises
    • 3. Text Formatting
    • 4. Link Exercises
    • 5. Image Exercises
  • CSS ▾
    • Style Gallery (6–10)
  • PHP ▾
    • 11. MySQL Integration
    • 12. Members Only
Home → CSS Style Gallery

CSS Style Gallery

Activities 6–10: CSS Margin, Padding, Outline, Table Styling, and Dimensions — demonstrated with live examples.

Activity 6 — CSS Margin

margin-left: 80px

This element has a left margin of 80px.
div { margin-left: 80px; }

margin-right: 80px

This element has a right margin of 80px.
div { margin-right: 80px; }

margin-top: 60px

This element has a top margin of 60px.
div { margin-top: 60px; }

margin-bottom: 30px

First element (30px below)
Element below
div { margin-bottom: 30px; }

margin shorthand

top:10 · right:40 · bottom:20 · left:60
div { margin: 10px 40px 20px 60px; }

Activity 7 — CSS Padding (Left)

padding-left: 60px

Left padding of 60px.
div { padding-left: 60px; }

padding-right: 60px

Right padding of 60px.
div { padding-right: 60px; }

padding-top: 40px

Top padding of 40px.
div { padding-top: 40px; }

padding-bottom: 40px

Bottom padding of 40px.
div { padding-bottom: 40px; }

padding shorthand

top:8 · right:30 · bottom:20 · left:50
div { padding: 8px 30px 20px 50px; }

Activity 8 — CSS Outline

outline-style

dotted
dashed
solid
double
groove
p { outline-style: dotted; } p { outline-style: dashed; } p { outline-style: solid; }

outline-width

thin
medium
thick
6px
p { outline-width: thin; } p { outline-width: thick; } p { outline-width: 6px; }

outline-color

red
blue
green
#ff6600
p { outline-color: red; } p { outline-color: blue; } p { outline-color: #ff6600; }

border + outline

Blue border + Green outline
div { border: 3px solid blue; outline: 3px dashed green; }

outline shorthand

outline shorthand applied
p { outline: dashed #2e7d32 4px; }

Activity 9 — CSS Table Styling

table border

NameAge
Alice22
Bob25
table, th, td { border: 1px solid green; }

border-spacing: 8px

NameGrade
AliceA
BobB
table { border-collapse: separate; border-spacing: 8px; }

caption-side: bottom

Table 1: Student Records
NameScore
Alice95
Bob88
table { caption-side: bottom; }

empty-cells: hide

NameScore
Alice95
Bob
table { empty-cells: hide; }

table-layout: fixed

NameDescription
AliceA very long description that gets clipped
table { table-layout: fixed; }

Activity 10 — CSS Dimensions

height: 100px

height: 100px
div { height: 100px; }

min-height: 80px

min-height: 80px — stays at least 80px tall.
div { min-height: 80px; }

max-height: 60px

max-height: 60px — content scrolls if it exceeds this height. Extra line. More text to demonstrate overflow behavior in action.
div { max-height: 60px; overflow: auto; }

width: 250px

width: 250px
div { width: 250px; }

min-width: 200px

min-width: 200px
div { min-width: 200px; }

max-width: 260px

max-width: 260px — will not grow beyond 260px.
div { max-width: 260px; }

line-height values

line-height: 0.9
Tight spacing.
line-height: 2.2
Wide spacing.
line-height: 36px
Fixed pixel spacing.
p { line-height: 0.9; } p { line-height: 2.2; } p { line-height: 36px; }

Mary Junnette M. Urtua  ·  BS InfoTech 3F  ·  2026