{"id":4473,"date":"2015-08-05T06:06:46","date_gmt":"2015-08-05T06:06:46","guid":{"rendered":"http:\/\/a1webdesignteam.com\/blog\/?p=4473"},"modified":"2015-08-05T06:06:46","modified_gmt":"2015-08-05T06:06:46","slug":"adding-css-to-html","status":"publish","type":"post","link":"https:\/\/a1webdesignteam.com\/blog\/adding-css-to-html\/","title":{"rendered":"Adding CSS to HTML"},"content":{"rendered":"<p>To add CSS in your HTML file.<\/p>\n<pre class=\"html\">\u2026\r\n&lt;<span class=\"function-name\">head<\/span>&gt;\r\n&lt;<span class=\"function-name\">link<\/span> <span class=\"variable-name\">rel<\/span>=<span class=\"string\">\"stylesheet\"<\/span> <span class=\"variable-name\">type<\/span>=<span class=\"string\">\"text\/css\"<\/span> <span class=\"variable-name\">href<\/span>=<span class=\"string\">\"mystyle.css\"<\/span>&gt;\r\n&lt;<span class=\"function-name\">title<\/span>&gt;<span class=\"underline\"><span class=\"bold\">My Title<\/span><\/span>&lt;\/<span class=\"function-name\">title<\/span>&gt;\r\n&lt;\/<span class=\"function-name\">head<\/span>&gt;\r\n\u2026<\/pre>\n<p>In the above example, whenever the HTML file is loaded, it will load the file <code class=\"path-\u03b1\">mystyle.css<\/code>. The <code>&lt;link \u2026&gt;<\/code> line must be inside the \u201chead\u201d tag.<\/p>\n<p>If you use the above for all your files, then you can control your whole site&#8217;s appearance by modifying the single CSS file.<\/p>\n<h3>CSS for Single HTML File<\/h3>\n<p>If you want to use CSS only for a single file, you can embed it in HTML file&#8217;s header using the <code>&lt;style&gt;<\/code> tag, like this:<\/p>\n<pre class=\"html\">\u2026\r\n&lt;<span class=\"function-name\">head<\/span>&gt;\r\n&lt;<span class=\"function-name\">title<\/span>&gt;<span class=\"underline\"><span class=\"bold\">My Title<\/span><\/span>&lt;\/<span class=\"function-name\">title<\/span>&gt;\r\n&lt;<span class=\"function-name\">style<\/span> <span class=\"variable-name\">type<\/span>=<span class=\"string\">\"text\/css\"<\/span>&gt;\r\np {color:red}\r\n\/* more CSS code here *\/\r\n&lt;\/<span class=\"function-name\">style<\/span>&gt;\r\n&lt;\/<span class=\"function-name\">head<\/span>&gt;\r\n\u2026<\/pre>\n<h3>CSS for Single HTML Tag<\/h3>\n<p>If you want to specify a style only for one particular HTML tag in a HTML file, you can embed a attribute <code>style=\"\u2026\"<\/code> inside the tag, like this:<\/p>\n<pre class=\"html\">&lt;<span class=\"function-name\">p<\/span>&gt;\u2026 this is &lt;<span class=\"function-name\">span<\/span> <span class=\"variable-name\">style<\/span>=<span class=\"string\">\"color:red\"<\/span>&gt;RED!&lt;\/<span class=\"function-name\">span<\/span>&gt;&lt;\/<span class=\"function-name\">p<\/span>&gt;\r\n\r\n&lt;<span class=\"function-name\">p<\/span> <span class=\"variable-name\">style<\/span>=<span class=\"string\">\"color:red\"<\/span>&gt;This whole paragraph is RED!&lt;\/<span class=\"function-name\">p<\/span>&gt;<\/pre>\n<h2>CSS Syntax<\/h2>\n<p>CSS source code looks like this:<\/p>\n<pre class=\"css\"><span class=\"css-selector\">p <\/span>{\r\n    <span class=\"css-property\">line-height<\/span>:1.5;\r\n    <span class=\"css-property\">width<\/span>:60ex;\r\n    <span class=\"css-property\">font-family<\/span>:sans-serif;\r\n}\r\n\r\n<span class=\"css-selector\">li <\/span>{\r\n    <span class=\"css-property\">margin-top<\/span>:0.8ex;\r\n    <span class=\"css-property\">color<\/span>:gray;\r\n}\r\n\r\n<span class=\"css-selector\">blockquote <\/span>{\r\n    <span class=\"css-property\">color<\/span>:blue;\r\n}\r\n\r\n<span class=\"css-selector\">img <\/span>{\r\n    <span class=\"css-property\">border<\/span>:solid thin black;\r\n}\r\n\r\n<span class=\"css-selector\"><span class=\"comment-delimiter\">\/* <\/span><\/span><span class=\"css-selector\"><span class=\"comment\">basic table style with border <\/span><\/span><span class=\"css-selector\"><span class=\"comment-delimiter\">*\/<\/span><\/span><span class=\"css-selector\">\r\ntable.xyz <\/span>{\r\n    <span class=\"css-property\">border<\/span>:1px solid black;\r\n    <span class=\"css-property\">border-collapse<\/span>:collapse;\r\n}\r\n\r\n<span class=\"css-selector\">table.xyz th, table.xyz td <\/span>{\r\n    <span class=\"css-property\">border<\/span>:1px solid gray;\r\n    <span class=\"css-property\">padding<\/span>:.5ex;\r\n}\r\n\r\n<span class=\"css-selector\"><span class=\"comment-delimiter\">\/* <\/span><\/span><span class=\"css-selector\"><span class=\"comment\">for programing language source code <\/span><\/span><span class=\"css-selector\"><span class=\"comment-delimiter\">*\/<\/span><\/span><span class=\"css-selector\">\r\nspan.code <\/span>{\r\n    <span class=\"css-property\">font-family<\/span>:monospace;\r\n    <span class=\"css-property\">color<\/span>:#00008d;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To add CSS in your HTML file. \u2026 &lt;head&gt; &lt;link rel=&#8221;stylesheet&#8221; type=&#8221;text\/css&#8221; href=&#8221;mystyle.css&#8221;&gt; &lt;title&gt;My Title&lt;\/title&gt; &lt;\/head&gt; \u2026 In the above example, whenever the HTML file is loaded, it will load the file mystyle.css. The &lt;link \u2026&gt; line must be inside the \u201chead\u201d tag. If you use the above for all your files, then you can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4474,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[5],"tags":[51],"_links":{"self":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts\/4473"}],"collection":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/comments?post=4473"}],"version-history":[{"count":0,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts\/4473\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/media\/4474"}],"wp:attachment":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/media?parent=4473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/categories?post=4473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/tags?post=4473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}