The use-case here would be if you have so much css and js that loading it all externally pushes you past an acceptable loading time threshold. While inlining critical assets would technically solve this problem, figuring out how to extract and load critical css/js inline is incredibly labor-intensive, and often results in very fragile build processes. It's often less labor-intensive to start stripping out code altogether, or subbing-in slimmer solutions. For existing projects, I'd recommend looking for low-hanging fruit first to reduce your bundle sizes. I'll often look for huge libraries that are being underutilized. I had a junior add loadash and import _ from 'lodash' the other day because they wanted to capitalize a string. Devs will import all of bootstrap or tailwind because they don't want to learn css grid. Stuff like that happens all the time and can result in enormous bundles. (bootstrap's grid alone is >4000 lines of css) On new projects, nip this in the bud by having a perf testing pipeline : Every time you add a package, you'll get a record of what that package does to your performance. This can help train you and your team to not just thoughtlessly npm i your troubles away. Every piece of code you write or include has consequences, If you don't consider those consequences from the start of a project, you end up in this situation where google shrugs and says: "your app is so bloated that your only hope of getting acceptable performance is to inline code" This is getting into "old man shouting at the sky" territory, but sticking to good web development principles (the rule of least power, progressive enhancement, semantic markup, etc) makes this so easy. Answer from _listless on reddit.com
🌐
ACTE
acte.in › home › explain internal css in html: stepwise implementation guide
Explain Internal CSS in HTML: Stepwise Implementation Guide | Updated 2025
CyberSecurity Framework and Implementation Article
Internal CSS: CSS Style Sheets That Are Embedded Directly Into an HTML Document. It Uses the Tag to Define and Apply Styles to the Elements of the Document. One of best Institute to learn CyberSecurity Framework and Implementation from ACTE . Really impressive model where you can learn technical Skills , Soft Skill and get help to kick start your first Job as well.
Rating: 5 ​
🌐
Reddit
reddit.com › r/webdev › are there situations in which inline/internal css and javascript is a good idea?
Are there situations in which inline/internal CSS and ...
August 9, 2023 -

Specially asking since audits like the one by Lighthouse often tells me to use inline CSS/JS ("Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles").

I always use external CSS and JS, but if I had to make a steelman, I'd guess it's a good idea to use inline JS and CSS for big elements that are supposed to load quickly/first.

Edit: thanks for the replies brothers.

Top answer
1 of 8
8
By "inline" I normally assume you mean as style attributes. In that case, maybe if you're fighting with a CMS and need to get something shipped immediately. Still, you should go back and clean that up when you have time. It's dirty and hacky. When Lighthouse says "inline" I normally assume that means to put the CSS and JS inside the HEAD element. Done correctly, it's going to have your pages loading as fast as possible. "Done correctly" being the important part. First off, that's going to be a PITA to maintain. You don't want to do this yourself. It should be part of a build process. Secondly, tree shaking. You don't want to put everything in the HEAD, just the CSS and JS necessary for the first page. Maybe even just the top of the first page. It's mostly useful for landing pages, where the user is unlikely to continue on to other pages. Also, it's terrible for development. Makes it very difficult to maintain even if you do have a good build process. There are almost always other things you can do to optimize your site before this will make a meaningful impact.
2 of 8
5
The use-case here would be if you have so much css and js that loading it all externally pushes you past an acceptable loading time threshold. While inlining critical assets would technically solve this problem, figuring out how to extract and load critical css/js inline is incredibly labor-intensive, and often results in very fragile build processes. It's often less labor-intensive to start stripping out code altogether, or subbing-in slimmer solutions. For existing projects, I'd recommend looking for low-hanging fruit first to reduce your bundle sizes. I'll often look for huge libraries that are being underutilized. I had a junior add loadash and import _ from 'lodash' the other day because they wanted to capitalize a string. Devs will import all of bootstrap or tailwind because they don't want to learn css grid. Stuff like that happens all the time and can result in enormous bundles. (bootstrap's grid alone is >4000 lines of css) On new projects, nip this in the bud by having a perf testing pipeline : Every time you add a package, you'll get a record of what that package does to your performance. This can help train you and your team to not just thoughtlessly npm i your troubles away. Every piece of code you write or include has consequences, If you don't consider those consequences from the start of a project, you end up in this situation where google shrugs and says: "your app is so bloated that your only hope of getting acceptable performance is to inline code" This is getting into "old man shouting at the sky" territory, but sticking to good web development principles (the rule of least power, progressive enhancement, semantic markup, etc) makes this so easy.
🌐
W3Schools
w3schools.com › html › html_css.asp
HTML Styles CSS
An internal CSS is defined in the <head> section of an HTML page, within a <style> element.
🌐
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
🌐
OneCompiler
onecompiler.com › html › 3wk45h2tv
Style (internal css) - HTML - OneCompiler
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
🌐
Roadtocode
spaceship.roadtocode.org › internship cohort program › inline, internal and external css
Inline, Internal and External CSS | Spaceship 🛸
Inline CSS => single element · Document level / Internal CSS · External CSS · Inline CSS are using the style attribute inside HTML elements. It is used to give CSS for individual HTML tags.
🌐
MilesWeb
milesweb.com › home › css style sheet types: inline, external, and internal [a beginner’s guide]
Types of CSS: Inline, External, and Internal [A Beginner’s Guide with Examples]
3 weeks ago - However, its excessive use is not recommended because inline CSS makes HTML code difficult to read and maintain. Internal CSS is used for styling a particular page or its section, but not an entire file.
Find elsewhere
🌐
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 - Internal CSS styles are included within the head section of an HTML document and apply to the entire document, allowing for consistent styling across multiple elements.
🌐
HubSpot
blog.hubspot.com › home › website › how to add css to html: understanding inline, internal & external css
How to Add CSS to HTML: Understanding Inline, Internal & External CSS
March 13, 2023 - Internal CSS, also called an embedded stylesheet, goes inside the HTML document. But instead of going inside the elements themselves, internal CSS is placed inside a <style> tag in the <head> section of the document.
🌐
Code Institute
codeinstitute.net › blog › css › internal css
Internal CSS: What is it and When to Use - Code Institute DE
April 24, 2023 - A CSS attribute and values are still set, but now they are enclosed in brackets and specified by a CSS selector rather than being contained within a style attribute. This rule set is then contained within the <style></style> tags and is located ...
🌐
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 - Below are examples of what the ... to use the HTML tags in the Head section of your webpage. All the code for the Internal CSS stylesheet is contained between the <head></head> section of your websites code....
🌐
Quora
quora.com › Whats-the-best-practice-inline-internal-or-external-CSS
What's the best practice: inline, internal or external CSS? - Quora
Answer (1 of 9): External CSS is the best practice. The reason is mostly about maintainability - but there are also some performance considerations as well. Internal CSS will overwrite external CSS, and inline styles will overwrite internal and external CSS - but using these often makes for mes...
🌐
CodeSweetly
codesweetly.com › inline-vs-internal-vs-external-css
Inline vs Internal vs External CSS – Learn the Difference | CodeSweetly
Use inline CSS sparingly because ... style declaration with a semicolon (;). ... An internal CSS styles multiple HTML elements within the document you used it....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Styling_basics › Getting_started
Getting started with CSS - Learn web development | MDN
The very first thing we need to do is to tell the HTML document that we have some CSS rules we want it to use. There are three different ways to apply CSS to an HTML document that you'll commonly come across — external stylesheets, internal stylesheets, and inline styles.
🌐
GeeksforGeeks
geeksforgeeks.org › css › internal-css
Internal CSS - GeeksforGeeks
June 24, 2024 - Internal CSS is a method for defining CSS styles directly within an HTML document.
🌐
GeeksforGeeks
geeksforgeeks.org › css › types-of-css-cascading-style-sheet
Types of CSS (Cascading Style Sheet) - GeeksforGeeks
Internal or Embedded CSS is defined within the HTML document's <style> element. It applies styles to specified HTML elements. The CSS rule set should be within the HTML file in the head section, i.e.
Published   July 11, 2025
🌐
HostPapa
hostpapa.com › home › hosting › understanding inline, internal, and external css styles
The difference between inline, internal, and external CSS styles
June 28, 2021 - An internal stylesheet holds CSS rules for the page in the head section of the HTML file. The rules only apply to that page, but you can configure CSS classes and IDs to style multiple elements in the page code.