What is CSS? Notes by home academy

 

What is CSS?

  • CSS stands for Cascading Style Sheets.

  • It is used to style and design HTML elements (e.g., colors, fonts, layout).

  • CSS separates content (HTML) from design (CSS).


📌 Key Features of CSS

FeatureDescription
Separation of ConcernsHTML for structure, CSS for style
ReusabilityOne CSS file can style multiple HTML pages
Cascading RulesStyles are applied based on priority
Responsive DesignSupports mobile-friendly layouts
LightweightMakes website faster and cleaner

📚 Syntax of CSS

css
selector { property: value; }

Example:

css
h1 { color: red; font-size: 24px; }

🧱 Types of CSS

TypeSyntax ExampleUsage
Inline CSS<h1 style="color:blue;">Hello</h1>Applies to one element
Internal CSSInside <style> in <head>Styles a single HTML page
External CSS<link rel="stylesheet" href="style.css">Best practice, styles multiple pages

🖌️ Common CSS Properties

PropertyDescriptionExample
colorText colorcolor: blue;
backgroundBackground color/imagebackground: yellow;
font-sizeSize of textfont-size: 20px;
font-familyFont stylefont-family: Arial;
borderBorder stylingborder: 1px solid red;
paddingInner spacingpadding: 10px;
marginOuter spacingmargin: 15px;
widthWidth of elementwidth: 300px;
heightHeight of elementheight: 200px;

🎯 CSS Selectors

Selector TypeSyntax ExampleDescription
Elementp {}Targets <p> tags
Class.className {}Targets all elements with that class
ID#idName {}Targets a specific element with that ID
Grouph1, p {}Styles multiple elements together
Universal* {}Applies to all elements

🧩 CSS Box Model

Each element is a box made of:

css
[ margin ] [ border ] [ padding ] [ content ]
css
div { margin: 10px; padding: 20px; border: 2px solid black; }

📐 Layout with CSS

1. Display Property

css
display: block | inline | flex | grid | none;

2. Positioning

css
position: static | relative | absolute | fixed | sticky;

3. Flexbox Example

css
.container { display: flex; justify-content: space-between; }

🌍 Responsive Web Design

Use media queries to make websites mobile-friendly.

css
@media screen and (max-width: 600px) { body { background-color: lightblue; } }

🎨 Pseudo-classes & Effects

Pseudo-classUse
:hoverOn mouse over
:focusWhen input is selected
:first-childFirst element in a group

Example:

css
button:hover { background-color: green; }

💼 Practical Applications of CSS

AreaApplication Example
Web DesignStyling websites
Mobile App UIHTML + CSS based UIs (e.g., PWA)
Email TemplatesProfessional, responsive email layouts
CMS ThemesWordPress themes are mostly CSS driven
Frontend FrameworksBootstrap, Tailwind CSS are CSS libraries

❓ Important MCQs for Exams

  1. CSS stands for:
    a) Computer Style Sheets
    b) Colorful Style Sheets
    c) Cascading Style Sheets ✅
    d) Creative Style Sheets

  2. Which HTML tag is used to link external CSS?
    a) <css>
    b) <link>
    c) <style>
    d) <script>

  3. How to apply CSS to all <p> tags?
    a) p.all
    b) #p
    c) p ✅
    d) .p

  4. Which property controls text size?
    a) font-size ✅
    b) text-style
    c) font-weight
    d) size

  5. What does #id selector do?
    a) Selects all tags
    b) Selects element with specific ID ✅
    c) Selects all classes
    d) None


📝 Conclusion

  • CSS is the backbone of web design.

  • It enhances the look and feel of webpages.

  • Combined with HTML + JavaScript, it forms the foundation of frontend development.

homeacademy

Home academy is JK's First e-learning platform started by Er. Afzal Malik For Competitive examination and Academics K12. We have true desire to serve to society by way of making educational content easy . We are expertise in STEM We conduct workshops in schools Deals with Science Engineering Projects . We also Write Thesis for your Research Work in Physics Chemistry Biology Mechanical engineering Robotics Nanotechnology Material Science Industrial Engineering Spectroscopy Automotive technology ,We write Content For Coaching Centers also infohomeacademy786@gmail.com

إرسال تعليق (0)
أحدث أقدم