{
    "componentChunkName": "component---src-templates-learn-js",
    "path": "/learn/css/including-css",
    "result": {"data":{"mdx":{"frontmatter":{"title":"Including CSS into HMTL","date":"March 12, 2022","tags":["css"],"description":"This tuts shows how to include  css into html "},"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Including CSS into HMTL\",\n  \"date\": \"2022-03-12\",\n  \"description\": \"This tuts shows how to include  css into html \",\n  \"tags\": [\"css\"],\n  \"type\": \"tuts\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar Callouts = makeShortcode(\"Callouts\");\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"There are three methods of including CSS into Html document.\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Inline Styles\"), mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Internal / Embedded Style\"), mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"External Stye\")), mdx(\"h3\", null, \"1. Inline Style :\"), mdx(\"p\", null, \"Inline styles are applying css styles direcly to tag using style attribute of a tag.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\",\n    \"metastring\": \"show=false\",\n    \"show\": \"false\"\n  }, \"<h1 style=\\\"color:red; font-size:30px;\\\">This is a heading</h1>\\n\")), mdx(\"p\", null, \"Inline styles takes \", mdx(\"strong\", null, \"highest priority\"), \" compared to Internal and External .\"), mdx(\"h3\", null, \"2. Internal /Embedded Style:\"), mdx(\"p\", null, \"Internal style sheets are defined in the Html head section using < style > element.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\",\n    \"metastring\": \"show=false highlights=5,13,18\",\n    \"show\": \"false\",\n    \"highlights\": \"5,13,18\"\n  }, \"<!DOCTYPE html>\\n<html lang=\\\"en\\\">\\n  <head>\\n    <title>First Page</title>\\n    <style>\\n      body {\\n        background-color: red;\\n      }\\n      p {\\n        color: #fff;\\n      }\\n    </style>\\n    <style>\\n      h1 {\\n        color: #010101;\\n      }\\n      p {\\n        color: red;\\n      }\\n    </style>\\n  </head>\\n  <body>\\n    <h1>Welcome :)</h1>\\n    <p>This is a text.</p>\\n  </body>\\n</html>\\n\")), mdx(\"p\", null, \"We can add multiple style elements inside one Html document.\"), mdx(Callouts, {\n    name: \"warning\",\n    mdxType: \"Callouts\"\n  }, \"Note: As you can see above, multiple styles applied to a p tag in the code. Css has mechanisms to apply styles based on priority ,order and specificity. In above case, it overrides #fff color code with red color as order of it is newest.\", mdx(\"p\", null, \"you will learning this in next section.\")), mdx(\"h3\", null, \"3. External StyleSheet\"), mdx(\"p\", null, \"External StyleSheet contains all the css styles and rules for the tags inside a separate document. we can apply those styles not\\nony one html page , we can link this to others page to apply styles.\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"create a new file name it as \\\"style.css\\\"\")), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-css\",\n    \"metastring\": \"file=style.css\",\n    \"file\": \"style.css\"\n  }, \"body {\\n  background: lightgreen;\\n  color: #fffff1;\\n}\\nh1 {\\n  font-size: 18px;\\n  color: green;\\n}\\n\")), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"link above style.css to our index.html page\")), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\",\n    \"metastring\": \"file=index.html highlights=5\",\n    \"file\": \"index.html\",\n    \"highlights\": \"5\"\n  }, \"<!DOCTYPE html>\\n<html lang=\\\"en\\\">\\n  <head>\\n    <title>First Page</title>\\n    <link rel=\\\"stylesheet\\\" href=\\\"style.css\\\" />\\n  </head>\\n  <body>\\n    <h1>Welcome</h1>\\n    <p>This is a text.</p>\\n  </body>\\n</html>\\n\")), mdx(Callouts, {\n    name: \"info\",\n    mdxType: \"Callouts\"\n  }, \" \", \"rel attribute is completely optional. As Css is a default stylesheet language for Html\"), mdx(\"h4\", null, \"Example :\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\",\n    \"metastring\": \"file=index.html highlights=5,6,13\",\n    \"file\": \"index.html\",\n    \"highlights\": \"5,6,13\"\n  }, \"<!DOCTYPE html>\\n<html lang=\\\"en\\\">\\n  <head>\\n    <title>First Page</title>\\n    <link rel=\\\"stylesheet\\\" href=\\\"style.css\\\" />\\n    <style>\\n      h1 {\\n        color: red;\\n      }\\n    </style>\\n  </head>\\n  <body>\\n    <h1 style=\\\"color : pink\\\">Welcome</h1>\\n    <p>This is a text.</p>\\n  </body>\\n</html>\\n\")), mdx(\"h4\", null, \"Q : can you guess which color will be applied to h1 tag at the end ?\"));\n}\n;\nMDXContent.isMDXComponent = true;","slug":"css/including-css"},"allMdx":{"edges":[{"node":{"slug":"css/anatomy-of-css","id":"7684434d-5c98-50dd-a6a0-b32b36aba480"}},{"node":{"slug":"css/how-css-works","id":"cf79d413-a0bf-515f-b48d-5c9b937d568a"}},{"node":{"slug":"css/including-css","id":"968cabd3-e50c-5651-a747-36c992134856"}},{"node":{"slug":"css/intro","id":"f0af023e-c1d2-5c2b-9289-f73b5228327b"}}]}},"pageContext":{"id":"968cabd3-e50c-5651-a747-36c992134856","filePath":"/css/","previousPostId":"css/how-css-works","nextPostId":"css/intro"}},
    "staticQueryHashes": ["2033233798"]}