CSS Introduction


🔹 What is CSS?

CSS stands for Cascading Style Sheets. It is used to control the style and layout of multiple web pages all at once.

With CSS, you can change:

  • Colors

  • Fonts

  • Spacing

  • Layouts

  • Animations


🔹 Why Use CSS?

  • Separation of content and design

  • Makes the website more attractive and user-friendly

  • Helps maintain consistency across pages

  • Saves time – styles can be reused via external stylesheets


🔹 CSS Syntax

selector {
  property: value;
}
 
Example:
p {
  color: red;
  font-size: 18px;
}
 

This CSS makes all <p> elements red and 18px in size.


🔹 Three Ways to Apply CSS

1. Inline CSS

Applied directly to an HTML element.

<p style="color:blue;">This is blue text.</p>
 
2. Internal CSS

Written inside a <style> tag in the <head>.

<head>
  <style>
    body {
      background-color: lightgrey;
    }
  </style>
</head>
 
3. External CSS

Stored in a separate .css file and linked using:

<link rel="stylesheet" href="styles.css">
 

🔹 CSS Selectors

Selector Description
* Selects all elements
p Selects all <p> elements
.class Selects all elements with a class
#id Selects an element with a specific ID
div p Selects all <p> inside <div>

Practice Questions

Q1. Make a heading text red using inline CSS.

Q2. Change body background using internal CSS.

Q3. Change paragraph font size using class.

Q4. Use external CSS to color a paragraph blue.

Q5. Change multiple properties of a div.

 
 
 

CSS Introduction Quiz

Q1: What does CSS stand for?

A. Computer Style Sheets
B. Creative Style Sheets
C. Cascading Style Sheets
D. Colorful Style Sheets

Q2: Which HTML tag is used to define internal CSS?

A. <script>
B. <css>
C. <style>
D. <link>

Q3: Which property is used to change text color?

A. font-color
B. text-color
C. color
D. text-style

Q4: How do you insert an external CSS file?

A. <script src="style.css">
B. <style src="style.css">
C. <link rel="stylesheet" href="style.css">
D. <css link="style.css">

Q5: Which symbol is used for class selectors in CSS?

A. #
B. .
C. *
D. %

Go Back Top