CSS Introduction
CSSCSS (Cascading Style Sheets) controls how HTML elements look — colors, fonts, spacing, layout.
HTML = structure. CSS = design. Together they create beautiful web pages.
3 Ways to Add CSS
- Inline — style attribute on element
- Internal — <style> tag in <head>
- External — separate .css file (recommended!)
/* External CSS file: style.css */
h1 {
color: #4f46e5;
font-size: 2rem;
text-align: center;
}
p {
color: #64748b;
font-size: 1.1rem;
line-height: 1.6;
}
Styled Heading
This paragraph is styled with CSS. Notice the color, size, and spacing.
Interview Questions — CSS Introduction
5 questions commonly asked in interviews
CSS stands for Cascading Style Sheets. It is used to style HTML elements and control layout, colors, fonts, spacing, and design.
There are three types: inline CSS, internal CSS, and external CSS.
External CSS is written in a separate .css file and linked to HTML using the <link> tag.
Cascading means styles are applied based on priority, specificity, and order.
CSS separates design from content and makes websites attractive, responsive, and easier to maintain.
Frequently Asked Questions
Common doubts about CSS Introduction
Yes, HTML can work without CSS, but the page will look plain.
External CSS is best for large websites because it is reusable and easy to maintain.
Yes, multiple CSS files can be linked in one HTML document.
No, CSS is a stylesheet language used for presentation.
Yes, CSS media queries, flexbox, and grid help create responsive layouts.
Test Your Knowledge
5 questions · Earn 50 XP
More on CSS Introduction
Cheatsheet, tips, resources & what to learn next
Quick Cheatsheet
<p style="color:red;">Hello</p>
<style>
p { color: blue; }
</style>
<link rel="stylesheet" href="style.css">
p { color: red; }
body { background-color: #f5f5f5; }
Pro Tips
Use external CSS for better maintainability.
Avoid too much inline CSS.
Keep CSS class names meaningful.
Use comments to organize large CSS files.
Use browser developer tools to test CSS quickly.