{"id":111,"date":"2021-06-03T22:06:52","date_gmt":"2021-06-03T21:06:52","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/?page_id=111"},"modified":"2024-06-05T11:05:35","modified_gmt":"2024-06-05T10:05:35","slug":"external-internal-and-inline","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/css\/external-internal-and-inline\/","title":{"rendered":"External, Internal and Inline"},"content":{"rendered":"<p>CSS commands can be placed in different locations.<\/p>\n<h1>External Style Sheets<\/h1>\n<p>All the CSS commands are stored in a separate file &#8211; often saved as <strong>styles.css<\/strong><\/p>\n<p>Changing or setting any properties in this file will affect every page in the website that uses the same stylesheet file.<\/p>\n<pre class=\"brush: css; title: styles.css; notranslate\" title=\"styles.css\">\r\np {\r\n    font-size: 18px;\r\n    color: darkgreen;\r\n}\r\n<\/pre>\n<pre class=\"brush: xml; highlight: [5]; title: HTML File; notranslate\" title=\"HTML File\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;#####&lt;\/title&gt;\r\n        &lt;link rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; href=&quot;styles.css&quot;&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        ###########\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n\r\n<\/pre>\n<h1>Internal Style Sheets<\/h1>\n<p>All the CSS commands are stored inside the &lt;style&gt; &lt;\/style&gt; tags in the &lt;head&gt; &lt;\/head&gt; section of the html page.<\/p>\n<pre class=\"brush: xml; highlight: [5,6,7,8,9,10]; title: HTML File; notranslate\" title=\"HTML File\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;#####&lt;\/title&gt;\r\n        &lt;style&gt;\r\n            p { \r\n                font-size: 18px; \r\n                color: darkred; \r\n            }\r\n        &lt;\/style&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        ###########\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n\r\n<\/pre>\n<p>Internal style sheets are best used when:<\/p>\n<ul>\n<li>a website only has one page<\/li>\n<li>one page in a website has to look different from the other pages.<\/li>\n<\/ul>\n<h1>Inline Styles<\/h1>\n<p>CSS style commands are embedded inside the html tags:<\/p>\n<pre class=\"brush: xml; title: HTML File; notranslate\" title=\"HTML File\">\r\n&lt;p style=&quot;font-size: 18px; color: darkblue;&quot;&gt;bla bla bla&lt;\/p&gt;\r\n<\/pre>\n<p>Inline styles should be avoided. They are difficult to read, and mix the page content with the formatting, making pages hard to update. Using a CSS <em>id<\/em> or <em>class<\/em> achieves the same result, but avoid the problems.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSS commands can be placed in different locations. External Style Sheets All the CSS commands are stored in a separate file &#8211; often saved as styles.css Changing or setting any properties in this file will affect every page in the website that uses the same stylesheet file. p { font-size: 18px; color: darkgreen; } &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;#####&lt;\/title&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; href=&quot;styles.css&quot;&gt; &lt;\/head&gt; &lt;body&gt; ########### &lt;\/body&gt; &lt;\/html&gt; Internal Style<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/css\/external-internal-and-inline\/\">Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":78,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-111","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":10,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/111\/revisions"}],"predecessor-version":[{"id":448,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/111\/revisions\/448"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/78"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/media?parent=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}