Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Inline vs External CSS | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 17 of 55

·HTML

Inline vs External CSS

7 min

Course progress31%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Differences between inline, internal, and external CSS
  • Performance impact of each method (HTTP requests, caching)
  • Maintainability considerations and best practices
  • When inline styles are acceptable (dynamic values, debugging)
  • Using preprocessors and naming conventions for scalable CSS

Where to Put CSS

MethodScopePerformanceMaintainability
Inline (style='…')Single element onlyNo extra HTTP request, but overrides all other stylesHard to manage, discouraged
Internal (<style>)Page‑specificCSS loaded with HTML, no extra requestBetter than inline but still mixes concerns
External (<link>)Site‑wide or sharedCached by browser, reduces HTML sizeClean separation of concerns, recommended

When to use inline styles

  • For dynamic values generated by JavaScript (e.g., element.style.width = '50%').
  • For quick debugging of a single element.

Best‑practice CSS workflow

  1. Write modular, component‑based CSS (BEM, CSS Modules, or utility‑first like Tailwind).
  2. Keep global styles in an external stylesheet.
  3. Add critical CSS inline only if you need to eliminate the first‑paint delay.

Quick checklist for styling approach

  1. Majority of styles in external files? ✅
  2. Internal <style> used only for critical CSS? ✅
  3. Inline style= avoided except for runtime changes? ✅
  4. Naming convention (BEM, OOCSS) in place? ✅

If any answer is “no”, reorganise your CSS now.

Tip: Use a CSS preprocessor (Sass, Less) or PostCSS to keep styles DRY and maintainable.

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
Previous lessonUsing CSS with HTML – `<link>` and `<style>`Continue to lesson 18Responsive Design – Meta Viewport and Media QueriesBack to HTML Course curriculum