Currently Empty: ₹0.00
CSS Introduction
CSS CODES & EXAMPLES
Introduction to CSS
Learn how to style HTML webpages using CSS. Explore selectors, colors, fonts, spacing, borders, backgrounds and the CSS box model with practical examples.
01
What is CSS?
Cascading Style Sheets
CSS stands for Cascading Style Sheets. It is used to control the appearance and layout of HTML elements on a webpage.
HTML creates the structure,
while CSS controls the design and presentation.
02
CSS Syntax
Basic CSS rule structure
syntax.css
selector {
property: value;
}
Example:
p {
color: blue;
font-size: 18px;
}
03
Inline CSS
CSS directly inside an HTML element
inline-css.html
<h1 style="color: blue;">
Welcome to CSS
</h1>
04
Internal CSS
CSS inside the HTML head section
internal-css.html
<style>
h1 {
color: blue;
}
p {
font-size: 18px;
}
</style>
05
External CSS
Connect a separate CSS file
index.html
<link
rel="stylesheet"
href="style.css">
06
Element Selector
Select HTML elements by tag name
element-selector.css
h1 {
color: darkblue;
}
p {
color: #555;
}
07
Class Selector
Select elements using a class
class-selector.css
.title {
color: blue;
font-size: 30px;
}
08
ID Selector
Select an element using an ID
id-selector.css
#main-title {
color: green;
font-size: 32px;
}
09
CSS Colors
Change text and element colors
colors.css
h1 {
color: blue;
}
p {
color: #333333;
}
.box {
background-color: rgb(230, 240, 255);
}
10
CSS Background
Style element backgrounds
background.css
body {
background-color: #f4f8fc;
}
.card {
background-color: white;
}
.hero {
background-image: url("image.jpg");
background-size: cover;
background-position: center;
}
11
CSS Fonts
Control font family and appearance
fonts.css
body {
font-family: Arial, sans-serif;
}
h1 {
font-size: 40px;
font-weight: 700;
}
p {
font-size: 16px;
}
12
CSS Text
Control text alignment and decoration
text.css
h1 {
text-align: center;
}
p {
line-height: 1.7;
letter-spacing: 0.3px;
}
a {
text-decoration: none;
}
13
CSS Borders
Add borders to elements
borders.css
.card {
border: 1px solid #dddddd;
border-radius: 12px;
}
.box {
border: 2px solid blue;
}
14
Margin
Create outside spacing
margin.css
.box {
margin: 20px;
}
.card {
margin-top: 30px;
margin-bottom: 20px;
}
15
Padding
Create inside spacing
padding.css
.card {
padding: 25px;
}
.button {
padding: 12px 20px;
}
16
Width and Height
Control element dimensions
dimensions.css
.box {
width: 300px;
height: 200px;
}
.container {
width: 100%;
max-width: 1200px;
}
17
CSS Box Model
Understand content, padding, border and margin
box-model.css
* {
box-sizing: border-box;
}
.card {
width: 300px;
padding: 20px;
border: 2px solid #ddd;
margin: 20px;
}
18
CSS Button
Create a modern button
button.css
.button {
display: inline-block;
padding: 12px 22px;
background: #1769d5;
color: white;
border-radius: 8px;
text-decoration: none;
font-weight: bold;
}
.button:hover {
background: #0d4e9f;
}
19
CSS Live Preview
See CSS styling in action
LIVE PREVIEW
20
Practice Task
Create your first styled webpage
🎯 Practice: Style a Student Card
Create an HTML student card and style it using CSS.
- Add a student name.
- Add a course name.
- Change the text color.
- Add a background color.
- Add padding and margin.
- Add a border and border-radius.
- Create a modern button.
- Add a hover effect.



