{"id":8096,"date":"2022-09-27T04:28:00","date_gmt":"2022-09-27T04:28:00","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=8096"},"modified":"2022-09-27T04:28:00","modified_gmt":"2022-09-27T04:28:00","slug":"html-styles-css","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/09\/27\/html-styles-css\/","title":{"rendered":"HTML Styles &#8211; CSS"},"content":{"rendered":"\n<p>CSS\u00a0is used to style\u00a0HTML. It determines how the\u00a0HTML elements\u00a0appear on the screen, paper, or in other media.<\/p>\n\n\n\n<p>CSS saves a lot of work. It can control the layout of several pages all at once.<\/p>\n\n\n\n<p>You can add CSS to HTML elements in 3 ways:<\/p>\n\n\n\n<ul><li>Inline, where the\u00a0style\u00a0attribute is used in HTML elements.<\/li><li>Internal, where the\u00a0&lt;style>\u00a0element is used in the\u00a0&lt;head>\u00a0section.<\/li><li>External, where an external CSS file is used.<\/li><\/ul>\n\n\n\n<p>Let\u2019s look through each way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"inline-css-2\">Inline CSS<\/h2>\n\n\n\n<p>An inline CSS applies a particular style to a single HTML element. Here the&nbsp;style&nbsp;attribute of an HTML element is used.<\/p>\n\n\n\n<p>In the example below the text color of the\u00a0&lt;p>\u00a0element is red:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-inline-css-4\">Example of the inline CSS:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Usage of the inline CSS&lt;\/h1&gt;\n    &lt;p style=\"color:red;\"&gt;The paragraph is red.&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"internal-css-6\">Internal CSS<\/h2>\n\n\n\n<p>An internal CSS specifies a style for a single HTML page. It is defined in the &lt;head&gt; element of an HTML page, inside of a &lt;style&gt; tag:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-internal-css-8\">Example of the internal CSS:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      body {\n        background-color: yellow;\n      }\n      h1 {\n        font-size: 30px;\n      }\n      p {\n        font-size: 18px;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Lorem Ipsum&lt;\/h1&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"external-css-10\">External CSS<\/h2>\n\n\n\n<p>An external style sheet specifies the style for multiple HTML pages. It can change the look of the whole website by changing just one file.<\/p>\n\n\n\n<p>For using an external style sheet, you should add a link to it inside of the element of the HTML page:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-external-css-sheet-12\">Example of the external CSS sheet:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;link rel=\"stylesheet\" href=\"styles.css\"&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Lorem Ipsum&lt;\/h1&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>The file can\u2019t contain any HTML code and must be saved with a .css extension.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"css-fonts-15\">CSS Fonts<\/h2>\n\n\n\n<p>The\u00a0CSS color\u00a0property describes the color of the text content.<\/p>\n\n\n\n<p>The\u00a0CSS font-family\u00a0property defines the font of the text content.<\/p>\n\n\n\n<p>The\u00a0CSS font-size\u00a0property defines the text size.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-css-fonts-17\">Example of the CSS fonts:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      h1 {\n        color: #008000;\n        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;\n        font-size: 200%;\n      }\n      p {\n        color: #666666;\n        font-family: 'New Roman', serif;\n        font-size: 150%;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Lorem Ipsum&lt;\/h1&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"css-border-19\">CSS Border<\/h2>\n\n\n\n<p>The\u00a0CSS border\u00a0property sets values to all four sides of an element.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-css-border-property-21\">Example of the CSS border property:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      p {\n        border: 2px dotted red;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Heading&lt;\/h1&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"css-padding-23\">CSS Padding<\/h2>\n\n\n\n<p>The\u00a0CSS padding\u00a0property specifies padding (space) between the text and the border.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-css-padding-property-25\">Example of the CSS padding property:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      p {\n        border: 2px dashed #008022;\n        padding: 50px;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Heading&lt;\/h1&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"css-margin-27\">CSS Margin<\/h2>\n\n\n\n<p>The\u00a0CSS margin\u00a0property creates space around the element.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-css-margin-property-29\">Example of the CSS margin property:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      p {\n        border: 2px dashed #090fce;\n        margin: 50px;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Heading&lt;\/h1&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-id-attribute-31\">The id Attribute<\/h2>\n\n\n\n<p>The\u00a0id attribute\u00a0specifies a specific style for one element.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-span-class-attribute-id-span-attribute-33\">Example of the&nbsp;id&nbsp;attribute:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      #large-text {\n        border: 8px groove powderblue;\n        font-size: 24px;\n        padding: 20px;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Heading&lt;\/h1&gt;\n    &lt;p id=\"large-text\"&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-class-attribute-35\">The Class Attribute:<\/h2>\n\n\n\n<p>The\u00a0class attribute\u00a0is used to specify a style for special kinds of elements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-span-class-attribute-class-span-attribute-37\">Example of the&nbsp;class&nbsp;attribute:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      .text {\n        border: 8px inset powderblue;\n        font-size: 20px;\n        padding: 10px;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Heading&lt;\/h1&gt;\n    &lt;p class=\"text\"&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n    &lt;p&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n    &lt;p class=\"text\"&gt;\n      Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CSS\u00a0is used to style\u00a0HTML. It determines how the\u00a0HTML elements\u00a0appear on the screen, paper, or in other media. CSS saves a lot of work. It can control the layout of several pages all at once. You can add CSS to HTML elements in 3 ways: Inline, where the\u00a0style\u00a0attribute is used in HTML elements. Internal, where the\u00a0&lt;style>\u00a0element [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[285],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/8096"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=8096"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/8096\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=8096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=8096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=8096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}