CSS Styling: Beyond the Basics

Take your CSS skills further by mastering text styling, the box model, backgrounds, and display properties to create visually appealing websites.
"If Card 1 was an introduction, Card 2 is where we start dressing up. Styling text to look neat and learning to space elements like a pro UI designer."

✍️ Text Styling (So It's Not Flat)

🔤 Text Styling Properties:

Property Function
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. And CSS helps you arrange these boxes like playing Tetris."

🧱 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 & border
  • Border: element's 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
🧠 Margin = gives the box space from others

📐 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:

Property Function
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 don't look as stiff as a deadline assignment!

🌫️ Box Shadow

Glow effects, neomorphism, or aesthetic shadows can be created with this:

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:

Type Effect
block Takes full width (like <div>, <p>)
inline Only as wide as content (like <span>, <a>)
inline-block Can 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
Your Logo