Inline CSS applies styles directly to an HTML element using the style attribute. It is specific to the individual element and overrides styles from internal or external CSS due to its high specificity.

  • Syntax: <element style="property: value; property: value;">Content</element>

  • Example: <p style="color: blue; font-size: 18px;">This is a styled paragraph.</p>

  • Use Cases:

    • Quick, one-off styling (e.g., debugging or testing).

    • Email templates (many email clients don’t support external stylesheets).

    • Dynamic styling via JavaScript (e.g., changing styles based on user interaction).

  • Drawbacks:

    • Not reusable—styles must be repeated for each element.

    • Hard to maintain—changes require editing every instance.

    • Increases HTML file size, impacting performance.

    • Breaks separation of concerns between HTML structure and CSS presentation.

While useful in specific scenarios, inline CSS should be used sparingly. For consistent, scalable styling, external or internal CSS is preferred.

Style rules can be attached using:

  • External Files
  • In-page Style Tags
  • Inline Style Attribute

Generally, I prefer to use linked style sheets because they:

  • can be cached by browsers for performance; and
  • are a lot easier to maintain for a development perspective.

However, your question is asking specifically about the style tag versus inline styles. Prefer to use the style tag, in this case, because it:

  • provides a clear separation of markup from styling;
  • produces cleaner HTML markup; and
  • is more efficient with selectors to apply rules to multiple elements on a page improving management as well as making your page size smaller.

Inline elements only affect their respective element.

An important difference between the style tag and the inline attribute is specificity. Specificity determines when one style overrides another. Generally, inline styles have a higher specificity.

Read CSS: Specificity Wars for an entertaining look at this subject.

Answer from jmbertucci on Stack Overflow
🌐
W3Schools
w3schools.com › html › html_css.asp
HTML Styles CSS
An inline CSS is used to apply a unique style to a single HTML element.
🌐
Codecademy
codecademy.com › article › html-inline-styles
Inline Styles in HTML: When to Use | Codecademy
The third place you can write CSS is inside of an HTML tag, using the style attribute. When CSS is written using the style attribute, it’s called an “inline style”. In general, this is not considered a best practice.
Discussions

html - Inline tags vs. inline css properties - Stack Overflow
What is the preferred method for setting CSS properties? Inline style properties: Style properties in More on stackoverflow.com
🌐 stackoverflow.com
Inline CSS vs Classes vs IDs - Styling (CSS) - Pinegrow Community Forum
Hello, Because Pinegrow and coding with it is still quite new to me, I wanted to ask the following simple question: What is the best / common way to work with inline CSS / classes / IDs? When I want to use a style on several objects, I use classes. But often I style objects that only appear ... More on forum.pinegrow.com
🌐 forum.pinegrow.com
0
March 13, 2021
When is inline CSS a good idea?
Rick Rakin is having issues with: I'm under the assumption never. But maybe not? Slacker Radio places it inline. slacker.com What are the pros/cons? More on teamtreehouse.com
🌐 teamtreehouse.com
10
May 31, 2013
inline Title alternative CSS
i can choose to not show the inline title at all, but then editing the file name becomes a pain in the ass. Can't it be edited from the title bar just above? More on reddit.com
🌐 r/ObsidianMD
7
11
October 18, 2022
🌐
W3Schools
w3schools.com › css › css_howto.asp
How to add CSS
Add External CSS Add Internal CSS Add Inline Style Multiple Style Sheets Code Challenge CSS Comments CSS Errors CSS Colors
🌐
Career Karma
careerkarma.com › blog › css › inline css: how to add css inline to a web page
Inline CSS: How to Add CSS Inline to a Web Page | Career Karma
December 29, 2020 - Inline CSS is used to apply CSS rules to a particular element on a web page. On Career Karma, learn how to use inline CSS.
🌐
npm
npmjs.com › package › inline-css
inline-css - npm
December 27, 2024 - This module takes html and inlines the CSS properties into the style attribute.
      » npm install inline-css
    
Published   Dec 27, 2024
Version   4.0.3
Author   Jonathan Kemp
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › display
display - CSS | MDN
5 days ago - The display CSS property sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex.
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › margin-inline
margin-inline - CSS | MDN
1 week ago - This property is a shorthand for the following CSS properties: ... /* <length> values */ margin-inline: 10px 20px; /* An absolute length */ margin-inline: 1em 2em; /* relative to the text size */ margin-inline: 5% 2%; /* relative to the nearest block container's width */ margin-inline: 10px; /* sets both start and end values */ margin-inline: anchor-size(width); margin-inline: calc(anchor-size(self-block) / 5) auto; /* Keyword values */ margin-inline: auto; /* Global values */ margin-inline: inherit; margin-inline: initial; margin-inline: revert; margin-inline: revert-layer; margin-inline: unset;
🌐
InMotion Hosting
inmotionhosting.com › inmotion hosting home › support › website › using external, internal css stylesheets and inline styles
Using External, Internal CSS Stylesheets and Inline Styles | InMotion Hosting
December 22, 2020 - It’s more a technique used for overriding inline styles (using the !important tag) where you need to decide when your CSS rule must override the inline CSS. Bear in mind that inline CSS is used to override the Internal or External CSS being applied at that point.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › inset-inline
inset-inline - CSS | MDN
February 12, 2026 - This property is a shorthand for the following CSS properties: ... /* <length> values */ inset-inline: 3px 10px; inset-inline: 2.4em 3em; inset-inline: 10px; /* value applied to start and end */ inset-inline: auto calc(anchor(self-start) + 20px); inset-inline: 400px anchor-size(--my-anchor height, 100px); /* <percentage>s of the width or height of the containing block */ inset-inline: 10% 5%; /* Keyword value */ inset-inline: auto; /* Global values */ inset-inline: inherit; inset-inline: initial; inset-inline: revert; inset-inline: revert-layer; inset-inline: unset;
🌐
GeeksforGeeks
geeksforgeeks.org › css › inline-css
Inline CSS - GeeksforGeeks
Inline CSS applies styles directly to HTML elements using the style attribute, allowing for quick, unique styling without external stylesheets.
Published   January 7, 2025
🌐
Mailchimp
templates.mailchimp.com › resources › inline-css
CSS Inliner Tool | Email Design Reference
We know that writing inline CSS is time consuming and repetitive, so we've built this conversion tool to automatically inline your email's CSS.
🌐
Hostinger
hostinger.com › home › tutorials › types of css: inline, external and internal definitions and differences explained
Types of CSS: Inline, Internal and External CSS Explained
April 23, 2025 - Here’s how Twitter will look ... of application. Inline CSS styles are included within the HTML document and are specific to individual HTML elements, allowing for targeted styling....
🌐
Pinegrow Community
forum.pinegrow.com › styling (css)
Inline CSS vs Classes vs IDs - Styling (CSS) - Pinegrow Community Forum
March 13, 2021 - Hello, Because Pinegrow and coding with it is still quite new to me, I wanted to ask the following simple question: What is the best / common way to work with inline CSS / classes / IDs? When I want to use a style on several objects, I use classes. But often I style objects that only appear ...
🌐
Substack
simonw.substack.com › p › agentic-engineering-patterns
Agentic Engineering Patterns
2 weeks ago - use the templates and CSS in this repo to create a new artifact with all HTML and CSS inline that shows me my homepage with some of those inline content types mixed in
🌐
Simplilearn
simplilearn.com › home › resources › software development › know all about inline css
Inline CSS Guide - How to use Inline Styles | Simplilearn
November 18, 2025 - Inline CSS is the technique to define the single element with the insert style sheets in an HTML document. Understand various concepts of CSS Inline using several example.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Quackit
quackit.com › css › inline_style_sheets.cfm
Inline Style Sheets
By this, I mean that instead of defining the style once, then applying the style against all instances of an element (say the <p> tag), you only apply the style to the instance you want the style to apply to. Actually, it's not really a style sheet as such, so a more accurate term would be inline styles. In the code below, we've added CSS by using inline styles.
🌐
Codespindle
codespindle.com › CSS › CSS-Inline-internal-external-stylesheets.html
Introduction to CSS-Inline-Internal-External-stylesheets
Inline styles, nestled within HTML element tags, offer a straightforward way to apply CSS directly to individual elements. They're perfect for quick fixes, experimenting with styles, or adding personalization.
🌐
The Odin Project
theodinproject.com › lessons › foundations-block-and-inline
Block and Inline | The Odin Project
In the previous lesson, we discovered that different display types have unique box models, and we can modify the box calculation by changing the box-sizing property. CSS has two box types: block and inline boxes, which determine element behavior and interaction.