Welcome to day three of our CSS journey! Today we’re going to focus on how colors, backgrounds, text and fonts can enhance a plain webpage into a visually appealing page. We will build a styled profile card while learning about various color systems, background properties, and text formatting options.
There is importance on understanding these concepts since this is the basis of web design. It doesn’t matter whether you’re building a personal portfolio, a business website or any web application, knowing how to work with colors and typography will help you create professional designs that you can communicate your message.
Let’s first include our basic HTML structure; the intention of this code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Styled Profile Card</title>
<link rel="stylesheet" href="Colors_Backgrounds.css">
</head>
<body>
<h1>overline text decoration</h1>
<h2>line through decoration</h2>
<h3>underline decoration</h3>
<h4>overline underline decoration</h4>
<div class="card">
<h1 class="name">Niotechone</h1>
<p class="bio">Frontend Developer who loves clean design, colors, and
fonts!</p>
</div>
<p class="over">Content to scroll...</p>
</body>
</html>
What this code does:
Why we do this:
Pro Tip: Always include <!DOCTYPE html> and remember to set the lang attribute to improve accessibility and browser compatibility.
Create a new file and call it Colors_Backgrounds.css, now let’s start applying styles:
/* Reset default margins and set a nice font */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
background-color: #f0f2f5;
padding: 20px;
}
What this code does:
Why we do this:
Let’s style our heading text decorations:
/* Text decoration examples */
h1 {
text-decoration: overline;
color: #2c3e50;
margin: 15px 0;
}
h2 {
text-decoration: line-through;
color: #e74c3c;
margin: 15px 0;
}
h3 {
text-decoration: underline;
color: #3498db;
margin: 15px 0;
}
h4 {
text-decoration: overline underline;
color: #9b59b6;
margin: 15px 0;
}
What this code accomplishes:
Why we do this:
Common Mistake to Avoid: Do not use text decorations excessively as it can make text hard to read. Apply decorations with purpose for emphasis.
Let’s build the access list out for your profile:
/* Profile card styling */
.card {
width: 350px;
margin: 30px auto;
padding: 30px;
background-color: white;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
text-align: center;
background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
position: relative;
overflow: hidden;
}
.card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 5px;
background: rgba(255, 255, 255, 0.3);
}
.name {
font-size: 28px;
font-weight: 700;
margin-bottom: 15px;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
text-decoration: none;
}
.bio {
font-size: 16px;
font-weight: 300;
line-height: 1.5;
opacity: 0.9;
}
What this code does:
Why we do this:
Pro Tip: Use rgba() colors for shadows to create a more natural, translucent look.
Let’s construct our scrollable paragraph, with background effects:
/* Scrollable content with background */
.over {
max-width: 800px;
margin: 40px auto;
padding: 25px;
background-color: white;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
max-height: 200px;
overflow-y: auto;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23f8f9fa"/><path d="M0 0L100 100M100 0L0 100" stroke="%23e9ecef" stroke-width="1"/></svg>');
background-size: 30px 30px;
background-attachment: local;
line-height: 1.7;
color: #495057;
}
What this code does:
Why we do this:
Color Systems in CSS
CSS offers a few different methods to choose colors:
/* Different color notation methods */
.color-examples {
color: red; /* Named color */
color: #ff0000; /* Hexadecimal */
color: rgb(255, 0, 0); /* RGB */
color: rgba(255, 0, 0, 0.5); /* RGB with alpha (transparency) */
color: hsl(0, 100%, 50%); /* HSL (Hue, Saturation, Lightness) */
color: hsla(0, 100%, 50%, 0.5); /* HSL with alpha */
}
How it works:
Why options:
Background Properties Deep Dive
Let’s look at the powerful background properties:
.background-example {
/* Single declaration */
background: color image repeat attachment position;
/* Individual properties */
background-color: #f0f8ff;
background-image: url('pattern.png');
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
background-attachment: fixed;
}
How it works:
Why do these matter:
1. Components / Keywords Used
Name | Description |
color | Sets the text color of an element |
background-color | Sets the background color of an element |
background-image | Sets one or more background images |
background-repeat | Defines how background images are repeated |
background-position | Sets the initial position of background images |
background-attachment | Defines if background scrolls with content or is fixed |
text-decoration | Adds decorations like underline, overline, line-through |
font-family | Specifies the font for text |
font-size | Sets the size of the font |
font-weight | Sets the thickness of the font (boldness) |
text-align | Aligns text horizontally |
line-height | Sets the space between lines of text |
2. Key Properties / Parameters / Features
Name | Description |
Hex Colors | 6-digit codes representing RGB values (e.g., #FF5733) |
RGB | Functional notation: rgb(red, green, blue) with values 0-255 |
RGBA | RGB with alpha channel for transparency (0-1) |
HSL | Hue (0-360), Saturation (0-100%), Lightness (0-100%) |
no-repeat | Background image appears only once |
fixed | Background doesn’t scroll with the page |
border-radius | Rounds the corners of elements |
box-shadow | Adds shadow effects around an element’s frame |
linear-gradient() | Creates a gradient background |
Index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Styled Profile Card</title>
<link rel="stylesheet" href="Index.css">
</head>
<body>
<h1>overline text decoration</h1>
<h2>line through decoration</h2>
<h3>underline decoration</h3>
<h4>overline underline decoration</h4>
<div class="card">
<h1 class="name">Niotechone</h1>
<p class="bio">Frontend Developer who loves clean design, colors, and fonts!</p>
</div>
<p class="over">Content to scroll...</p>
</body>
</html>
Index.css:
/* Reset default margins and set a nice font */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
background-color: #f0f2f5;
padding: 20px;
}
/* Text decoration examples */
h1 {
text-decoration: overline;
color: #2c3e50;
margin: 15px 0;
}
h2 {
text-decoration: line-through;
color: #e74c3c;
margin: 15px 0;
}
h3 {
text-decoration: underline;
color: #3498db;
margin: 15px 0;
}
h4 {
text-decoration: overline underline;
color: #9b59b6;
margin: 15px 0;
}
/* Profile card styling */
.card {
width: 350px;
margin: 30px auto;
padding: 30px;
background-color: white;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
text-align: center;
background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
position: relative;
overflow: hidden;
}
.card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 5px;
background: rgba(255, 255, 255, 0.3);
}
.name {
font-size: 28px;
font-weight: 700;
margin-bottom: 15px;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
text-decoration: none;
}
.bio {
font-size: 16px;
font-weight: 300;
line-height: 1.5;
opacity: 0.9;
}
/* Scrollable content with background */
.over {
max-width: 800px;
margin: 40px auto;
padding: 25px;
background-color: white;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
max-height: 200px;
overflow-y: auto;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23f8f9fa"/><path d="M0 0L100 100M100 0L0 100" stroke="%23e9ecef" stroke-width="1"/></svg>');
background-size: 30px 30px;
background-attachment: local;
line-height: 1.7;
color: #495057;
}
Congratulations! You have explicitly learned how to:
The big takeaway here is that in order to create a visually pleasing website, you need to learn how to put colors, backgrounds, type and typography that looks nice together. But once you see how things can be put together nicely, you can take basic HTML and create professional looking designs quickly.
Continue to experiment! Try replacing color schemes, changing font, or creating your own gradient combinations. Practice and experimentation is the best way to master these concepts!
All three work well, but HSL is considered the most designer-friendly because it allows easy control over hue, saturation, and lightness. HEX is commonly used for static colors, while RGBA is great when you need transparency.
Google Fonts provide better typography, brand consistency, modern styles, and guaranteed cross-device rendering. System fonts vary across devices and may break UI consistency.
Use trusted tools like Google Fonts Pairings, Fontjoy, or Fontpair. A good rule is:
It happens when you're using background-size incorrectly. Use:
Use inspiration tools like:
This keeps your design balanced and professional.
Copyright © 2026 Niotechone Software Solution Pvt. Ltd. All Rights Reserved.