SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 12 of 35

HTML CSS: Inline, Internal & External Stylesheets

4 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.

Diagram — see how it fits together
Infographic: parts of a CSS rule

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.

What CSS is

CSS stands for Cascading Style Sheets. It is a separate language that controls how HTML looks — colours, fonts, sizes, spacing, and layout. HTML builds the structure; CSS paints it. One CSS rule can style a hundred elements at once, which is why real websites keep their CSS in one place instead of repeating it.

Syntax — the three ways to add CSS

Here are all three methods in short form. Inline is quickest for one element. Internal is good for one page. External is the professional choice for a whole website.

<!-- 1. Inline: inside the tag -->
<p style="color: red;">Red text.</p>

<!-- 2. Internal: in the head -->
<style>p { color: red; }</style>

<!-- 3. External: a separate file -->
<link rel="stylesheet" href="style.css">
Note: The word "cascading" means the rules flow down and combine. If two rules style the same element, the more specific one wins — and an inline style beats both internal and external CSS. This order is called specificity, and you will use it every day.
Tip: Start with an external file even for small practice sites. Create style.css next to your HTML file, link it in the <head>, and keep all your styles in one place. Changing one line then changes the whole site.

Common mistakes

  • Forgetting to link the stylesheet — if nothing is styled, check the <link> tag and the file name first.
  • Writing CSS rules inside the HTML body — <style> belongs in the <head>.
  • Using an inline style for something repeated on many elements — that is what classes are for.
  • Forgetting the dot in a class selector — .myclass in CSS, class="myclass" in HTML.

Example explained

  • <style> sits inside the <head> and holds the page's internal CSS, so the rules apply to the whole page without repeating them on every element.
  • h1 { color: navy; } is a rule with the selector h1 — it makes the heading navy blue.
  • .intro { color: green; font-size: 18px; } targets only elements with class="intro" — the first paragraph turns green and larger, while the other paragraph is untouched.
  • <p style="color: red;"> is inline CSS, written directly on the tag — it styles just that one paragraph and beats the internal rules.

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: Inline, Internal & External Stylesheets

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What is CSS?

CSS stands for Cascading Style Sheets. It is the language that controls how a web page looks: colours, fonts, spacing, and layout.

2. What are the three ways to add CSS to a page?

Inline CSS in the style attribute, internal CSS in a style element in the head, and external CSS in a separate .css file linked from the page.

3. Why is external CSS the best way for real websites?

One file styles the whole website. Change one line in the CSS file and every page updates at once.

Why learn this yourself — and not just ask AI?

AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.

Get certified — just ₹10

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

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

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

Summer Training in Python Programming 2026
₹3,000
View
Core Python Programming – 3 Month Complete Course
₹700
View
AI Prompt Engineering Webinar 2026
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
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...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →