Protected Learning Content

AICPE Gurukul content is created for learning purposes. Printing, copying and unauthorized reuse are restricted.

AICPE Learning Hub HTML with CSS
Chapter 13
Introduction to CSS
Chapter 13 | Styling Begins

Introduction to CSS

HTML creates the structure of a webpage, but CSS makes it attractive. In this chapter, you will learn how CSS changes colors, fonts, spacing, backgrounds, borders and layouts.

Design

CSS adds colors, fonts, backgrounds and visual beauty.

Spacing

CSS controls margin, padding, width, height and alignment.

Layout

CSS helps arrange sections, cards, menus and grids.

Responsive Design

CSS makes webpages fit mobile, tablet and desktop screens.

Learning Objectives

After This Chapter, You Will Understand

This chapter introduces CSS in a simple and practical way.

CSS Meaning

Understand what CSS is and why it is used.

CSS Syntax

Understand selector, property and value.

CSS Methods

Learn inline, internal and external CSS.

Selectors

Understand how CSS selects HTML elements.

CSS Meaning

What is CSS?

CSS stands for Cascading Style Sheets. It is used to design HTML webpages.

1 Simple Meaning

CSS controls how HTML content looks on the screen. It can change text color, font size, background, borders, spacing, alignment, button design, card layout and responsive behavior.

Definition: CSS is a stylesheet language used to control the visual presentation of HTML webpages.
Easy Memory: HTML is the structure. CSS is the design. JavaScript is the action.

Before CSS vs After CSS

Before CSS

Plain HTML text with default browser design.

After CSS

Beautiful layout, better colors and spacing.

CSS Syntax

Selector, Property and Value

Every CSS rule has a selector and a declaration block.

2 CSS Rule Structure

selector {
    property: value;
}

The selector chooses the HTML element. The property tells what you want to change. The value tells how it should be changed.

3 Example

h1 {
    color: blue;
    font-size: 36px;
}
Meaning: Select all h1 headings and make their color blue and font size 36 pixels.
CSS Part Meaning Example
Selector Selects HTML element h1
Property Style feature to change color
Value New setting for property blue
Declaration Property and value pair color: blue;
Adding CSS

Three Ways to Add CSS

CSS can be added using inline, internal or external methods.

1. Inline CSS

CSS is written directly inside an HTML tag using the style attribute.

<h1 style="color:blue;">Hello</h1>

2. Internal CSS

CSS is written inside the style tag in the head section.

<style>
h1 {
  color: blue;
}
</style>

3. External CSS

CSS is written in a separate .css file and linked to HTML.

<link rel="stylesheet" href="style.css">
Best Professional Practice: Use external CSS for real websites because it keeps design separate from HTML and makes maintenance easier.
CSS Selectors

Basic CSS Selectors

Selectors tell CSS which HTML elements should be styled.

Element Selector

Selects all elements of a tag.

p {
  color: gray;
}

Class Selector

Selects elements with a class name.

.card {
  padding: 20px;
}

ID Selector

Selects one unique element with an ID.

#header {
  background: navy;
}
Quick Memory: Element selector uses tag name. Class selector uses dot. ID selector uses hash.
Try It Yourself

Create Your First CSS Styled Page

Edit the CSS and click Run Code to see the design change.

HTML + CSS Code Edit and run
Output Preview Browser result
Practice Task: Change the h1 color, card background, button color and paragraph font size.
Common Mistakes

Mistakes Students Should Avoid

CSS becomes easy when syntax and file linking are handled carefully.

Wrong Habits

  • Forgetting semicolon after CSS declarations
  • Missing closing curly bracket
  • Writing property spelling incorrectly
  • Using inline CSS everywhere
  • Linking the wrong CSS file path

Correct Habits

  • Write CSS in clean blocks
  • Use external CSS for real projects
  • Use class names for reusable design
  • Keep CSS file path correct
  • Test design changes in browser regularly
Remember: CSS is sensitive to spelling, symbols and brackets. A missing bracket can affect the design below it.
Quick Quiz

Test Your Understanding

Select the correct answers and check your score.

1. CSS stands for:

CSS stands for Cascading Style Sheets.

2. CSS is mainly used for:

CSS is used to style and design webpages.

3. In CSS, which part selects the HTML element?

The selector chooses the HTML element to style.

4. Which method is best for real websites?

External CSS is best for real websites because it keeps design separate and reusable.

5. Which symbol is used for class selector?

A class selector starts with a dot, for example .card.
Quick Revision

Remember These Points

Revise these before moving to Chapter 14.

CSS

CSS stands for Cascading Style Sheets and is used to design HTML webpages.

Selector

A selector chooses which HTML element should be styled.

Property

A property is the style feature you want to change.

Value

A value tells how the selected property should appear.

External CSS

External CSS keeps design in a separate .css file.

Class Selector

A class selector starts with a dot and can be reused on multiple elements.