{"id":729,"date":"2019-10-30T08:03:15","date_gmt":"2019-10-30T08:03:15","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/difference-between-inline-external-and-internal-css\/"},"modified":"2025-12-02T15:34:37","modified_gmt":"2025-12-02T15:34:37","slug":"difference-between-inline-external-and-internal-css","status":"publish","type":"post","link":"\/ca\/tutorials\/difference-between-inline-external-and-internal-css","title":{"rendered":"Types of CSS: inline, external and internal definitions and differences explained"},"content":{"rendered":"<p>CSS defines the front-end appearance of your website. There are several types of CSS, among them are inline and external CSS.<\/p><p>In short, the main difference between inline CSS and external CSS is that the former is processed faster as it only requires the browser to download one file, while external CSS will require downloading HTML and CSS files separately.<\/p><p>In this tutorial, we&rsquo;ll go in-depth comparing the three types of CSS styles &ndash; inline CSS, external CSS, and internal CSS. We&rsquo;ll also uncover the advantages and disadvantages of using each method.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/CSS-3-Cheatsheet.pdf\" target=\"_blank\" rel=\"noopener\">Download complete CSS cheat sheet<\/a><\/p><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-css\">What Is CSS<\/h2><p>Cascading Style Sheets (CSS) is a markup language responsible for how your web pages will look like. It controls the colors, fonts, and layouts of your website elements.<\/p><p>This style sheet language also allows you to add effects or animations to your website. You can use it to display some CSS animations like click button effects, spinners or loaders, and animated backgrounds.<\/p><p>Without CSS, your website will appear as a plain <a href=\"\/ca\/tutorials\/what-is-html\" target=\"_blank\" rel=\"noopener noreferrer\">HTML page<\/a>. Here&rsquo;s how <a href=\"https:\/\/twitter.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Twitter<\/a> will look like if we disable its CSS:<img decoding=\"async\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/example-of-a-website-without-css.png\" alt=\"Example of a website without CSS\"><\/p><p><div class=\"protip\">\n                    <h2 class=\"featured-snippet title\">What's the Difference Between Inline, External and Internal CSS Styles?<\/h2>\n                    <p>The main difference between Inline, external and internal CSS Styles is their location and scope of application. 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, allowing for consistent styling across multiple elements. External CSS styles are stored in a separate file and can be linked to multiple HTML documents, allowing for global styling across an entire website. <\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-internal-css\">Internal CSS<\/h3><p>Internal or embedded CSS requires you to add a <strong>&lt;style&gt;<\/strong> tag in the <strong>&lt;head&gt;<\/strong> section of your HTML document.<\/p><p>This CSS style is an effective method of styling a single page. However, using this style for multiple pages is time-consuming as you need to put CSS rules on every page of your website.<\/p><p>Here&rsquo;s how you can use internal CSS:<\/p><ol class=\"wp-block-list\">\n<li>Open your HTML page and locate <strong>&lt;head&gt;<\/strong> opening tag.<\/li>\n\n\n\n<li>Put the following code right after the <strong>&lt;head&gt;<\/strong> tag<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;style type=\"text\/css\"&gt;<\/pre><ol class=\"wp-block-list\" start=\"3\">\n<li>Add CSS rules on a new line. Here&rsquo;s an example:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">body {\n    background-color: blue;\n}\nh1 {\n    color: red;\n    padding: 60px;\n}\n\nType the closing tag:\n\n&lt;\/style&gt;<\/pre><p class=\"ql-syntax\">Your HTML file will look like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;style&gt;\nbody {\n    background-color: blue;\n}\nh1 {\n    color: red;\n    padding: 60px;\n} \n&lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;h1&gt;Hostinger Tutorials&lt;\/h1&gt;\n&lt;p&gt;This is our paragraph.&lt;\/p&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre><p><strong>Advantages of Internal CSS:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>You can use class and <a href=\"https:\/\/www.bitdegree.org\/learn\/css-id\" target=\"_blank\" rel=\"noopener noreferrer\">ID selectors<\/a> in this style sheet, like the following example:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.class {\n    property1 : value1; \n    property2 : value2; \n    property3 : value3; \n}\n\n#id {\n    property1 : value1; \n    property2 : value2; \n    property3 : value3; \n}\n<\/pre><ul class=\"wp-block-list\">\n<li>Since you&rsquo;ll only add the code within the same HTML file, you don&rsquo;t need to upload multiple files.<\/li>\n<\/ul><p><strong>Disadvantages of Internal CSS:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>Adding the code to the HTML document can increase the page&rsquo;s size and loading time.<\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-external-css\">External CSS<\/h3><p>With external CSS, you&rsquo;ll link your web pages to an external <strong>.css<\/strong> file, which can be created by any text editor in your device (e.g., <a href=\"https:\/\/notepad-plus-plus.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Notepad++<\/a>).<\/p><p>This CSS type is a more efficient method, especially for styling a large website. By editing one <strong>.css<\/strong> file, you can change your entire site at once.<\/p><p>Follow these steps to use external CSS:<\/p><ol class=\"wp-block-list\">\n<li>Create a new <strong>.css<\/strong> file with the text editor, and add the style rules. For example:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.xleftcol {\n   float: left;\n   width: 33%;\n   background:#809900;\n}\n.xmiddlecol {\n   float: left;\n   width: 34%;\n   background:#eff2df;\n}\n&#65279;<\/pre><ol class=\"wp-block-list\" start=\"2\">\n<li>In the <strong>&lt;head&gt;<\/strong> section of your HTML sheet, add a reference to your external <strong>.css<\/strong> file right after <strong>&lt;title&gt;<\/strong> tag:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"style.css\" \/&gt;<\/pre><p>Don&rsquo;t forget to change <strong>style.css<\/strong> with the name of your&nbsp;<strong>.css&nbsp;<\/strong>file.<\/p><p><strong>Advantages of External CSS:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>Since the CSS code is in a separate document, your HTML files will have a cleaner structure and are smaller in size.<\/li>\n\n\n\n<li>You can use the same <strong>.css<\/strong> file for multiple pages.<\/li>\n<\/ul><p><strong>Disadvantages of External CSS:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>Your pages may not be rendered correctly until the external CSS is loaded.<\/li>\n\n\n\n<li>Uploading or linking to multiple CSS files can increase your site&rsquo;s download time.<\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-inline-css\">Inline CSS<\/h3><p>Inline CSS is used to style a specific HTML element. For this CSS style, you&rsquo;ll only need to add the <strong>style<\/strong>&nbsp;attribute to each HTML tag, without using selectors.<\/p><p>This CSS type is not really recommended, as each HTML tag needs to be styled individually. Managing your website may become too hard if you only use inline CSS.<\/p><p>However, inline CSS in HTML can be useful in some situations. For example, in cases where you don&rsquo;t have access to CSS files or need to apply styles for a single element only.<\/p><p>Let&rsquo;s take a look at an example. Here, we add an inline CSS to the <strong>&lt;p&gt;<\/strong> and <strong>&lt;h1&gt;<\/strong> tag:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;body style=\"background-color:black;\"&gt;\n\n&lt;h1 style=\"color:white;padding:30px;\"&gt;Hostinger Tutorials&lt;\/h1&gt;\n&lt;p style=\"color:white;\"&gt;Something usefull here.&lt;\/p&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n&#65279;<\/pre><p><strong>Advantages of Inline CSS:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>You can easily and quickly insert CSS rules into an HTML page. That&rsquo;s why this method is useful for testing or previewing the changes and performing quick fixes to your website.<\/li>\n\n\n\n<li>You don&rsquo;t need to create and upload a separate document as in the external style.<\/li>\n<\/ul><p><strong>Disadvantages of Inline CSS:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>Adding CSS rules to every HTML element is time-consuming and makes your HTML structure messy.<\/li>\n\n\n\n<li>Styling multiple elements can affect your page&rsquo;s size and download time.<\/li>\n<\/ul><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-web-hosting\" href=\"\/ca\/web-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>In this tutorial, you&rsquo;ve learned the difference between the three types of CSS &ndash; internal, external, and inline, and their uses in website development. Given that each type has its own advantages and disadvantages, it&rsquo;s important to know your goal before using a specific type for your website.<\/p><p>To recap, here are the three types of CSS:<\/p><ul class=\"wp-block-list\">\n<li><strong>Internal or embedded<\/strong> &#8288;&ndash; add <strong>&lt;style&gt;<\/strong> tag in the <strong>&lt;head&gt;<\/strong> section of HTML document<\/li>\n\n\n\n<li><strong>External<\/strong> &#8288;&ndash; link the HTML sheet to a separate <strong>.css<\/strong> file<\/li>\n\n\n\n<li><strong>Inline<\/strong> &#8288;&ndash; apply CSS rules for specific elements.<\/li>\n<\/ul><p>We hope that this article helps you understand the differences between the three types of CSS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSS defines the front-end appearance of your website. There are several types of CSS, among them are inline and external CSS. In short, the main difference between inline CSS and external CSS is that the former is processed faster as it only requires the browser to download one file, while external CSS will require downloading [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/difference-between-inline-external-and-internal-css\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":139793,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"Types of CSS: Inline, Internal and External CSS Explained","rank_math_description":"This article will explain the three types of CSS along with the advantages and disadvantages of each type.","rank_math_focus_keyword":"types of css","footnotes":""},"categories":[22656,22658],"tags":[],"class_list":["post-729","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website","category-website-development"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/difference-between-inline-external-and-internal-css","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/diferenca-entre-estilos-css","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/style-css","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/tipos-de-estilos-css","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/perbedaan-inline-css-external-css-dan-internal-css","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/difference-between-inline-external-and-internal-css","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/difference-between-inline-external-and-internal-css","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/difference-between-inline-external-and-internal-css","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/tipos-de-estilos-css","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/tipos-de-estilos-css","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/tipos-de-estilos-css","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/diferenca-entre-estilos-css","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/difference-between-inline-external-and-internal-css","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/difference-between-inline-external-and-internal-css","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/difference-between-inline-external-and-internal-css","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/difference-between-inline-external-and-internal-css","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=729"}],"version-history":[{"count":24,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/729\/revisions"}],"predecessor-version":[{"id":138861,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/729\/revisions\/138861"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media\/139793"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}