What Is CSS And Why We Use CSS

 


  • What is CSS?
  1. CSS stands for Cascading Style Sheets
  2. CSS describes how HTML elements are to be displayed on screen, paper, or in other media
  3. CSS saves a lot of work. It can control the layout of multiple web pages all at once
  4. External stylesheets are stored in CSS files
  • Why Use CSS?
  1. CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes
  • Some Common CSS Mistakes Should be Avoid 
  • Don't Use PX when it's not Needed
    [ Bad ]
    .class-name {
    
padding: 10px 0px;
    }
    [ Good ]
    .class-name {
    
padding: 10px 0;
    }
  • Use Shorthand properties 
    [ Bad ]
    .class-name {
     margin-top: 10px;
    margin-bottom: 10px;
     margin-left: 10px;
    margin-right: 10px;
    }
    [ Good ]
    .class-name {
    margin: 10px;
    }
  • Do Not Repeat Same Code
    [ Bad ]
    .class-name {
    margin: 10px;
     padding: 10px;
    }

    .other-class-name {
    margin: 10px;
     padding: 10px;
    }
    [ Good ]
    .class-name, .other-class-name {
    margin: 10px;
     padding: 10px;
    }
  • Use Color Code Instead Of Color Name
    [ Bad ]
    .class-name {
    color: black
    }
    [ Good ]
    .class-name {
    color: #000000
    }

Thanks...

Comments

Popular Posts

Laravel Hidden Eloquent Memory Leak: Why Your App Crashes with Large Data

Laravel Performance Optimization: 15 Proven Tips to Make Your App Faster (2026)

Laravel vs Node.js: Which Is Better for Web Development in 2026?