SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
Lesson 12 of 30

HTML CSS

2 min read · Free · No login needed

CSS (Cascading Style Sheets) is the language that controls how a web page looks: colours, fonts, spacing, layout. HTML builds the structure; CSS paints it. There are three ways to add CSS to a page.

1. Inline CSS

Written in the style attribute of one element: <p style="color: red;">. Quick for testing, but bad for real pages — the same style must be repeated on every element.

2. Internal CSS

Written once inside a <style> element in the <head>. It applies to the whole page. Good for a single page, but every page needs its own copy.

3. External CSS (the right way)

Written in a separate .css file and linked from the page: <link rel="stylesheet" href="styles.css">. One file styles the whole website. Change one line in the CSS file and every page updates at once. This is how every professional website works — including kamaldnp.com.

How CSS selects elements

A CSS rule has a selector and a declaration. The selector says which elements to style; the declaration says how. For example, h1 { color: navy; } makes every h1 navy. .intro { font-size: 18px; } styles every element with class "intro". #header { background: orange; } styles the one element with id "header".

Tip: The word "cascading" means that when several rules match the same element, the most specific one wins — and inline styles beat everything. Keep this in mind when a style does not seem to apply.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>CSS</title>
<style>
h1 { color: navy; }
.intro { color: green; font-size: 18px; }
</style>
</head>
<body>

<h1>Styled Heading</h1>
<p class="intro">This paragraph uses a class.</p>
<p style="color: red;">This one uses inline CSS.</p>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML CSS
Try it yourself: copy the code above into a file named test.html, open it in your browser, and change the text to see what happens. That is how you learn — by changing things and watching the result.
Get certified — just ₹10

Finish all 30 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test
Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

Advanced Cyber Security Industrial Training
₹5,000
View
CapCut Mobile Video Editing Course Beginner to Advance
₹99
View
Core Python Programming – 3 Month Complete Course
₹700
View
Browse all courses
HTML — Lessons
1. HTML Introduction 2. HTML Editors 3. HTML Basic 4. HTML Elements 5. HTML Attributes 6. HTML Headings 7. HTML Paragraphs 8. HTML Styles 9. HTML Formatting 10. HTML Comments 11. HTML Colors 12. HTML CSS 13. HTML Links 14. HTML Images 15. HTML Favicon 16. HTML Page Title 17. HTML Tables 18. HTML Lists 19. HTML Block and Inline Elements 20. HTML Div 21. HTML Classes 22. HTML Id 23. HTML Iframes 24. HTML JavaScript 25. HTML File Paths 26. HTML Head 27. HTML Layout 28. HTML Responsive 29. HTML Semantics 30. HTML Forms
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🛡️ 7-Day Money-Back Guarantee
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Download karne ke liye login karo. Login ke baad yahi page pe rahoge!

Naya ho? Register karo →