Description

CSS (Cascading Style Sheets) is used to control how a website looks, including colours, typography, spacing, layouts, and responsive behaviour. While HTML provides structure, CSS defines presentation: how elements are positioned, how large they appear, and how they adapt to different screen sizes. CSS can be applied globally across a site using shared styles, making it easier to maintain consistent branding. Modern CSS supports flexible layouts with tools like Flexbox and Grid, and it uses media queries to adjust designs for mobile, tablet, and desktop. Separating styling from structure improves maintainability and makes updates faster across multiple pages.

Why it Matters?

  • Controls design elements like colours, fonts, and spacing.
  • Supports consistent branding across the website.
  • Enables responsive layouts for different devices.
  • Makes site-wide design updates more efficient.

Key Factors

  • Selectors: Target specific HTML elements to apply styles.
  • Typography rules: Control fonts, sizes, line height, and readability.
  • Layout systems: Use Grid/Flexbox to organise page structure.
  • Responsive rules: Media queries adapt styling to screen sizes.
  • Cascade and specificity: Determine which rules take priority.

Best Practices

  • Organise CSS logically (base, layout, components).
  • Use consistent spacing and typography scales.
  • Build responsive layouts with Grid or Flexbox.
  • Avoid overly specific selectors where possible.
  • Test styling across devices and browsers.

FAQs

What is CSS?

CSS is a stylesheet language used to control the visual appearance and layout of webpages.

What does CSS do?

It defines colours, fonts, spacing, and layout behaviour, including responsive adjustments for different devices.

Why separate CSS from HTML?

It makes websites easier to maintain by keeping structure (HTML) and styling (CSS) distinct.

Recent Articles