{"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\"><div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                   What's the Difference Between Inline, External and Internal CSS Styles?\n                <\/p>\n            <\/div>\n            <p class=\"protip__content\">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><\/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><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:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/public\" 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-GB","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}]}}