Logo LIBR
Halo

Portfolio

Back to Blog
8 min read
CSS ModuleMay 19, 2025

CSS Styling: Beyond the Basics

CSS, Web Design, Styling
Syifa Fauziyah Arizal

Take your CSS skills further by mastering text styling, the box model, backgrounds, and display properties to create visually appealing websites.

If CSS Basics introduced the fundamentals, this lesson is where we start making interfaces look polished. You'll learn how to style text, manage spacing, customize backgrounds, and control how elements behave on the page.

Text Styling

Text Styling Properties

PropertyFunction
colorText color
font-sizeFont size (px, rem, %, etc)
font-familyFont type
font-weightFont thickness (normal, bold, 500, etc)
text-alignAlignment (left, right, center, justify)
line-heightLine spacing
letter-spacingLetter spacing
text-transformChange case (uppercase/lowercase/capitalize)

Example

CSS
p {
  font-family: 'Poppins', sans-serif;
  font-size: 18px;
  color: #333;
  text-align: justify;
  line-height: 1.8;
  text-transform: capitalize;
}

Your paragraphs won't just be readable, they'll look good too.

Box Model: Understanding HTML's Box World

"All HTML elements are essentially boxes. CSS helps you arrange these boxes like building a layout system."

Box Model consists of

Box Model
Margin: outer space
Border: edge line
Padding: inner space
Content: actual content

Explanation

  • Content: main content (text/image)
  • Padding: space between content and border
  • Border: element edge line
  • Margin: space between elements

Styling Example

CSS
.box {
  width: 300px;
  height: 200px;
  padding: 20px;
  margin: 40px auto;
  border: 2px solid #ff4d4d;
  background-color: #fff0f5;
}

Padding gives content breathing room, while margin creates space between elements.

Width & Height

Important properties

  • width → element width
  • height → element height

Units you can use:

  • px → fixed
  • % → relative to parent
  • vw/vh → relative to screen size
CSS
.card {
  width: 80%;
  height: auto;
}

Background Styling

Commonly used properties

PropertyFunction
background-colorBackground color
background-imageBackground image
background-sizeImage size (cover, contain)
background-repeatRepeat image or not
background-positionImage position (center, top, etc)
CSS
body {
  background-color: #f0f0f0;
  background-image: url('bg.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

Border & Radius

Border properties

CSS
.box {
  border: 3px dashed #ff69b4;
  border-radius: 12px;
}
  • border: edge line (solid, dashed, dotted)
  • border-radius: makes corners rounded

Perfect for styling cards so they feel more modern and approachable.

Box Shadow

Glow effects, depth, and elevation can all be created using box-shadow.

CSS
.card {
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
}

General format:

CSS
box-shadow: x-offset y-offset blur color;

Block vs Inline vs Inline-block

Element display types

TypeEffect
blockTakes full width (like div and p)
inlineOnly as wide as content (like span and a)
inline-blockCan set width/height but stays inline

Example

CSS
span {
  display: inline-block;
  width: 100px;
  height: 100px;
}

Key Takeaways

  • Can style text so it's not stiff
  • Understand box model & how to manage spacing
  • Play with background, border, shadow for aesthetics
  • Know the difference between block vs inline vs inline-block

More to read