CSS Introduction

CSS stands for Cascading Style Sheets. It is the language that controls how HTML elements look on a web page: colours, fonts, spacing, size and layout. HTML builds the structure, and CSS makes it beautiful.


A first example

Here is the same HTML, first without CSS and then with CSS.

<h1>Welcome</h1>
<p>This is my page.</p>
Without CSS

Welcome

This is my page.

h1 {
  color: white;
  background-color: teal;
  padding: 10px;
  text-align: center;
}

p {
  font-family: Georgia, serif;
  font-size: 18px;
}
With CSS

Welcome

This is my page.


Why use CSS?

  • Separation: HTML keeps the content, CSS keeps the design. Both are easier to manage.
  • One file, many pages: change one CSS file and the whole website changes.
  • Faster pages: the browser downloads the CSS file once and keeps it in the cache.
  • Responsive design: CSS makes the same page fit phones, tablets and desktops.

What does “cascading” mean?

A page can get style rules from many places: the browser, an external file, the page itself and inline styles. When rules clash, CSS has a fixed order to decide the winner. This is the cascade. You will learn it in CSS Specificity.


CSS versions

CSS3 is not one big document. It is split into modules, like Selectors, Backgrounds, Flexbox and Grid, and each module moves forward by itself. So today we simply say “CSS”.


Summary


Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
Explain the various ways to apply CSS styles to a web page
What are the advantages of CSS?
What is CSS?
What is the difference between link and @import in CSS?
What are CSS variables?
What is a CSS reset?