Code Baaj

No 1 Digital Knowledge Website

What is CSS | Full Information ?

Here is complete information about CSS (Cascading Style Sheets) β€” one of the core technologies of web development.


🎨 What is CSS?

CSS stands for Cascading Style Sheets. It is a stylesheet language used to control the presentation and layout of HTML documents. CSS defines how HTML elements should appear on the screen, paper, or other media.


🧾 1. History of CSS

FeatureDetails
Created byHΓ₯kon Wium Lie
First Released1996 (CSS1 by W3C)
Maintained byWorld Wide Web Consortium (W3C)
Latest versionCSS3 (modular, continuously evolving)

🧠 2. Why Use CSS?

  • Separates content from design (HTML for structure, CSS for style)
  • Makes websites look attractive and consistent
  • Enables responsive designs for different devices
  • Reduces code duplication with reusable styles

🧰 3. Key Features of CSS

FeatureDescription
CascadingStyles are applied in a specific order (priority-based)
SelectorsTarget HTML elements to apply styles
Responsive DesignMedia queries adjust layout for different screen sizes
Box ModelControls layout using margin, border, padding, content
Animations/TransitionsEnables visual effects like fades, slides, etc.

πŸ”§ 4. Types of CSS

  1. Inline CSS – Inside an HTML element (not recommended for large projects) <h1 style="color:red;">Hello</h1>
  2. Internal CSS – Inside <style> tag within an HTML file <style> h1 { color: blue; } </style>
  3. External CSS – In a separate .css file, linked via <link> <link rel="stylesheet" href="style.css">

🧱 5. Basic CSS Syntax

selector {
  property: value;
}

Example:

h1 {
  color: blue;
  font-size: 24px;
}

🎯 6. Selectors in CSS

Selector TypeExampleDescription
Universal*Selects all elements
ElementpTargets all <p> elements
Class.boxTargets elements with class=”box”
ID#mainTargets element with id=”main”
Descendantdiv pTargets <p> inside a <div>
Pseudo-classa:hoverWhen mouse hovers over a link

πŸ“ 7. CSS Box Model

Every HTML element is a box made of:

+--------------------------+
|      Margin              |
|  +--------------------+  |
|  |     Border         |  |
|  |  +--------------+  |  |
|  |  |  Padding      |  |  |
|  |  |+------------+|  |  |
|  |  ||  Content   ||  |  |
|  |  |+------------+|  |  |
|  |  +--------------+  |  |
|  +--------------------+  |
+--------------------------+

πŸ“± 8. Responsive Design with Media Queries

@media (max-width: 768px) {
  body {
    background-color: lightgray;
  }
}

This changes the background color for screens smaller than 768px.


✨ 9. CSS3 Features

FeatureDescription
FlexboxLayout model for aligning elements
Grid Layout2D layout system for building web grids
Media QueriesResponsive styles based on screen/device
AnimationsCreate animated effects using @keyframes
TransitionsSmooth changes between property values
Custom Properties (CSS Variables)Reusable dynamic values
Shadows & GradientsStylish visual effects

🎨 10. CSS Example – Styling a Card

.card {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  padding: 20px;
  max-width: 300px;
  margin: auto;
}

🧠 11. CSS Frameworks

Frameworks make styling faster and more consistent:

FrameworkPurpose
BootstrapResponsive grid, components, utilities
TailwindUtility-first CSS framework
BulmaModern, simple CSS framework
FoundationAdvanced, responsive design

πŸ”„ 12. CSS vs Other Styling Options

FeatureCSSInline StylesJavaScript Styling
PerformanceFastSlowerCan be slower
ReusabilityHighLowMedium
Best ForLayout/designQuick fixes/testingDynamic changes

βœ… 13. Pros and Cons of CSS

βœ”οΈ Pros:

  • Clean separation of structure (HTML) and style
  • Easy to maintain and scale
  • Flexible and powerful for layout
  • Compatible with all browsers

❌ Cons:

  • Can become hard to manage in large projects without structure
  • Browser compatibility issues (older versions)
  • Steep learning curve for layout systems (e.g., Grid, Flexbox)

πŸ“Œ Summary

TopicKey Points
LanguageStyle Sheet Language
PurposeTo style HTML content
Core FeatureSelectors, Box Model, Layout, Animation
VersionsCSS1, CSS2, CSS3
Use CasesWeb design, layout, responsive styling

Leave a Reply

Your email address will not be published. Required fields are marked *