What is CSS and what is it used for?
CSS (Cascading Style Sheets: cascading style sheets), is a language responsible for the appearance and styling of web pages. If HTML is the "skeleton" and structure of a page (headings, text, images, buttons), then CSS is the "clothes and makeup" that make a site attractive and easy to use.
What CSS is used for
CSS lets you:
- Customize the appearance of elements
- colors, sizes, fonts, spacing, shadows, borders, and so on.
- Control the layout of blocks on a page
- align elements, create columns, grids, and responsive layouts.
- Create responsive design
- so the site looks good on a phone, tablet, and computer.
- Create animations and visual effects
- smooth appearances, hover effects, button and transition animations.
- Separate logic from presentation
- HTML is responsible for content, CSS for style, which makes the code clearer and easier to maintain.
Short analogy
| Technology | Responsible for |
|---|---|
| HTML | structure and content |
| CSS | appearance, style, presentation |
| JavaScript | behavior and interactivity |
Simple example
HTML:
html
<p>Hello, world!</p>CSS:
css
p {
color: red;
font-size: 20px;
}This CSS will make the text red and larger.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.