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 I mean in my answer is that inline styles only affect the element they are present on, nothing else. 2012-08-17T22:15:21.753Z+00:00 ... Also a plus for a page style block is it simplifies the movement of the style to an external CSS page. 2013-10-28T11:11:15.207Z+00:00 ... @jmbertucci : I wouldn't have changed the topic of the question. How you can apply rules like@import or@font-face from a style attribute? I'm also saying this because I'm in a case I'm allowed an html ... More on stackoverflow.com
🌐 stackoverflow.com
Inline styles for a:link, a:hover etc in an email newsletter - HTML & CSS - SitePoint Forums | Web Development & Design Community
Help! Need to push out this email campaign now. CSS not supported in some email clients, so I need to set inline styles for the text links. Can’t seem to get it right. CSS below. My attempt at inline css inside the container div. Not working. I am new at this. I love it. Help me out? CS More on sitepoint.com
🌐 sitepoint.com
0
February 1, 2010
css - What's the difference between inline styles vs classes? - Stack Overflow
In my head, I've always known to use classes over inline styles for any project. But are there any effective differences between the two? ... If the HTML is built or generated independent of the overall site design (e.g. shared template code), then add reasonably-named classes and IDs, linked ... More on stackoverflow.com
🌐 stackoverflow.com
html - Inline Styles with - Stack Overflow
I am trying to make my link url font bigger in size and in bold, Without changing the css. I am trying to use inline styles. I expected this line to work: More on stackoverflow.com
🌐 stackoverflow.com
🌐
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 - Inline CSS styles are included within the HTML document and are specific to individual HTML elements, allowing for targeted styling. Internal CSS styles are included within the head section of an HTML document and apply to the entire document, ...
🌐
Mimo
mimo.org › glossary › html › inline-style
HTML Inline Style Attribute: Syntax, Usage, and Examples
The HTML inline style attribute applies CSS styles directly to an element. Unlike internal or external stylesheets, inline styles affect only the specific element where they are defined.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › style
<style>: The Style Information element - HTML | MDN
December 15, 2025 - The <style> HTML element contains style information for a document, or part of a document. It contains CSS, which is applied to the contents of the document containing the <style> element. <style> p { color: #26b72b; } code { font-weight: bold; } </style> <p> This text will be green. Inline styles take precedence over CSS included externally.
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › inline-style-in-html
Inline Style in HTML – CSS Inline Styles
November 7, 2024 - Inline takes precedence over all other styles. Any styles defined in the internal and external style sheets are overridden by inline styles. You can quickly and easily insert CSS rules into an HTML page, which is useful for testing or previewing changes and performing quick fixes on your website.
🌐
W3Schools
w3schools.com › html › html_styles.asp
HTML Styles
The HTML style attribute is used to add styles to an element, such as color, font, size, and more.
🌐
Newline
newline.co › 30-days-of-webdev › day-10-how-to-link-css-to-html-inline-style-and-stylesheets
How to Link CSS to HTML: Inline style and Stylesheets
April 28, 2023 - To use an Internal stylesheet on our "css-practice.html" file we need to both add a <head></head> element and the <style></style> element. There are some small syntax differences between adding Inline style vs. the other methods. Unlike Inline styles, Internal and External stylesheets require you identify the element you want to add the style to and then surround the CSS in curly braces.
🌐
SitePoint
sitepoint.com › html & css
Inline styles for a:link, a:hover etc in an email newsletter - HTML & CSS - SitePoint Forums | Web Development & Design Community
February 1, 2010 - Help! Need to push out this email campaign now. CSS not supported in some email clients, so I need to set inline styles for the text links. Can’t seem to get it right. CSS below. My attempt at inline css inside the conta…
🌐
W3Schools
w3schools.com › css › css_inline-block.asp
CSS inline-block
.nav { background-color: lightgray; list-style-type: none; padding: 0; margin: 0; } .nav li { display: inline-block; font-size: 18px; padding: 15px; } Try it Yourself » ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Top answer
1 of 11
42

First of all:

  • If the HTML is built or generated independent of the overall site design (e.g. shared template code), then add reasonably-named classes and IDs, linked exclusively to external stylesheet(s). Use sufficient elements to allow for arbitrary CSS manipulation. For example, see the CSS Zen Garden. This applies to ALL CMSes, programs, scripts, and other dynamically-generated site content. The HTML output must contain absolutely no styling or layout of any sort at all. No exceptions.

Assuming you're dealing with static content, then:

  • If there's any way you can reuse the style, make it a class and link to a stylesheet.

  • If there's no way would ever reuse the style (it's a one-off thing that doesn't make sense anywhere else) then use a <style> block that references the element's #id.

  • If the CSS attribute only makes sense in the context of the surrounding HTML (e.g. some usages of clear:) then I inline the style into the element.

A lot of people call this heresy, just like a lot of people denounce any use of goto in modern programming languages.

However, rather than subscribing to stylistic dogma, my view is you should choose the method based on your circumstances that decreases your overall workload the most. Stylesheets add a level of indirection that makes site-level changes easy and helps build consistency. But if you have several dozen classes on each page that are only used in one place, then you're actually increasing your workload, not decreasing it.

In other words, don't do something dumb and confusing just because people tell you it's the right way to do it.

2 of 11
34

There is a simple reason. The point of CSS is to separate the content (HTML) from the presentation (CSS). It's all about accessibility and code reuse.

🌐
W3Schools
w3schools.com › css › css_howto_inline.asp
How To Add Inline CSS
Tip: An inline style loses many of the advantages of a style sheet (by mixing content with presentation). Use this method sparingly. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
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
🌐
Reddit
reddit.com › r/css › are you really *never* supposed to use inline styles?
r/css on Reddit: Are you really *never* supposed to use inline styles?
April 13, 2023 -

I am relatively new to CSS. I understand the rationale for not needlessly cluttering your HTML with constant, repeated styles. Like, if I have a bazillion elements that need a set of shared values, okay, great, I'll make a class. Or, if I have an element that needs a bazillion styles, I'll make a class.

The part that frustrates me is when I have, for example, some random <p> tag that just needs a different color. Should I really be writing some crap like this:

.someclass .anotherclass > p { color: salmon; }

in order to target that ultra-specific <p> tag, or should I just chuck that color inline, i.e. <p style="color: salmon;"> and forget about it? Because the latter is definitely more convenient.

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