Introduction to CSS


What is CSS?

CSS stands for Cascading Style Sheets.

Let’s break down this term word by word:

  • Cascading means priority order. If there are multiple styles written for the same element, CSS follows rules to decide which style will win and apply. This is called CSS Specificity and Cascade Order.
  • Style means the visual appearance like colors, spacing, layout, font, border, size, etc.
  • Sheet means a file or code block that contains style rules.

Therefore,

CSS is used to control the style and layout of web pages.

HTML is used to create the structure (like text, images, headings, links).

CSS is used to design or style that structure (like colors, font sizes, spacing, layout, etc.).

Example:

If HTML:

<p>This is a paragraph.</p>

CSS:

p {
  color: blue;
  font-size: 20px;
}

This will make the paragraph text blue and 20px in size.


Difference between HTML CSS and JS

Difference between CSS, HTML, and JavaScript

FeatureHTMLCSSJavaScript
PurposeCreates structure and contentApplies design, layout, and visual stylingAdds interactivity and dynamic behavior
Language TypeMarkup LanguageStyle Sheet LanguageProgramming Language
File Extension.html.css.js
Browser RoleTells browser what to showTells browser how it should lookTells browser how it should behave
Example<h1>Title</h1>h1 { color: red; }alert(“Hello”);
ExecutesParsed as markupParsed and applied during renderingExecuted by browser’s JavaScript Engine


Components of CSS:

components of CSS
PartExplanationExample
SelectorTells which HTML element to targetp, h1, .box, #main
PropertyWhat style you want to change (like color, font)color, font-size, margin
ValueHow you want the style to appearblue, 20px, center
DeclarationOne line of property and valuecolor: red;
Rule SetFull block of selector and declarationsp { color: red; }

Example:

p {
  color: blue;
  font-size: 18px;
}
  • p:  This means apply styles to all <p> tags
  • color: blue; : Makes the text color blue
  • font-size: 18px;: Sets the font size to 18 pixels

✅Follow us for more updates:

Follow on LinkedIn Join WhatsApp Channel

CSS

Scroll to Top