{"id":5640,"date":"2025-07-08T11:21:37","date_gmt":"2025-07-08T15:21:37","guid":{"rendered":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/?post_type=chapter&#038;p=5640"},"modified":"2025-12-13T15:00:21","modified_gmt":"2025-12-13T20:00:21","slug":"html-and-css-basics","status":"publish","type":"chapter","link":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/chapter\/html-and-css-basics\/","title":{"raw":"HTML and CSS Basics","rendered":"HTML and CSS Basics"},"content":{"raw":"<div class=\"textbox outer\">\r\n<h2>Basics of HTML and CSS in<\/h2>\r\n<div class=\"textbox inner\">\r\n<h2>Pressbooks<\/h2>\r\n<\/div>\r\nHTML structures web content, while CSS styles it. Together, they control how your textbook looks and feels.\r\n\r\n<\/div>\r\nPressbooks uses both HTML (HyperText Markup Language) and CSS (Cascading Style Sheets) behind the scenes. Understanding how markup language and style sheets function together will help you grasp foundational web design parameters and accessibility principles. The following basics may be of interest to those working with preset themes, but they are essential for anyone attempting to customize their book.\r\n<div class=\"menu-table-wrapper h5p-display\" style=\"flex-direction: column;\">\r\n<span class=\"menu-table-title\">Basics of<\/span>\r\n<div class=\"menu-table\" style=\"flex-direction: row;\"><a class=\"menu-table-panel html-css-panel\" href=\"#html\">HTML\r\n<span style=\"font-size: 0.6em;\">(HyperText Markup Language)<\/span><\/a>\r\n<a class=\"menu-table-panel html-css-panel\" href=\"#css\">CSS\r\n<span style=\"font-size: 0.6em;\">(Cascading Style Sheets)<\/span><\/a><\/div>\r\n<\/div>\r\n<h2><a id=\"html\"><\/a>HTML (HyperText Markup Language)<\/h2>\r\nHTML is the language used to structure content on the web. It consists of elements (or \"tags\") that define different parts of your content, such as headings, paragraphs, lists, and links.\r\n\r\nFor example:\r\n<div class=\"code-textbox-outer\">\r\n<pre class=\"code-textbox-title\">  HTML:\r\n<\/pre>\r\n<pre class=\"code-textbox-inner\">&lt;h1&gt; <span class=\"black-text\">This is a Heading<\/span> &lt;\/h1&gt;\r\n&lt;p&gt; <span class=\"black-text\">This is a paragraph of text.<\/span> &lt;\/p&gt;\r\n  \r\n&lt;ul&gt;\r\n  &lt;li&gt; <span class=\"black-text\">First item<\/span> &lt;\/li&gt;\r\n  &lt;li&gt; <span class=\"black-text\">Second item<\/span> &lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\r\n<\/div>\r\n<h3>HTML Key Elements to Know<\/h3>\r\n<strong>Headings:<\/strong> Structure your text into hierarchical levels (e.g. <span class=\"inline-code green-text\">&lt;h1&gt;<\/span>, <span class=\"inline-code green-text\">&lt;h2&gt;<\/span>).\r\n\r\n<strong>Paragraphs:<\/strong> Use <span class=\"inline-code green-text\">&lt;p&gt;<\/span> for blocks of text.\r\n\r\n<strong>Lists:<\/strong> Organize items using ordered <span class=\"inline-code green-text\">&lt;ol&gt;<\/span> or unordered <span class=\"inline-code green-text\">&lt;ul&gt;<\/span> lists.\r\n\r\n<strong>Links:<\/strong> Create hyperlinks with the <span class=\"inline-code green-text\">&lt;a&gt;<\/span> tag (e.g. <span class=\"inline-code green-text\">&lt;a <span class=\"red-text\">href<\/span><span class=\"blue-text\">=\"https:\/\/link.com\"<\/span>&gt;<span class=\"black-text\"> Link <\/span>&lt;\/a&gt;<\/span>).\r\n\r\n<strong>Images:<\/strong> Add visuals with the <span class=\"inline-code green-text\">&lt;img&gt;<\/span> tag (e.g. <span class=\"inline-code green-text\">&lt;img <span class=\"red-text\">src<\/span><span class=\"blue-text\">=\"image.jpg\"<\/span> <span class=\"red-text\">alt<\/span><span class=\"blue-text\">=\"Description\"<\/span>&gt;<\/span>).\r\n<h3>HTML Exercise<\/h3>\r\nTry to understand the HTML content in your Pressbooks project by clicking on the Text (HTML) tab in the Edit Part\/Chapter page. Take great caution when trying to change any of the HTML tags.\r\n\r\n<hr \/>\r\n\r\n<h2><a id=\"css\"><\/a>CSS (Cascading Style Sheets)<\/h2>\r\nCSS is the language used to style HTML content. It defines how elements look\u2014their colours, fonts, sizes, and layout. In Pressbooks, CSS customizations let you modify the visual appearance of your book.\r\n<h3>How CSS Works<\/h3>\r\nCSS uses \"selectors\" to target HTML elements and apply \"rules\" that style them.\r\n\r\nFor example:\r\n<div class=\"code-textbox-outer\">\r\n<pre class=\"code-textbox-title\">  CSS:\r\n<\/pre>\r\n<pre class=\"code-textbox-inner\"><span class=\"black-text\"><span class=\"blue-text\">h1<\/span> {\r\n  colour: <span class=\"blue-text\">blue<\/span>;\r\n  font-size: <span class=\"green-text\">24px<\/span>;\r\n}\r\n\r\n<span class=\"blue-text\">p<\/span> {\r\n  line-height: <span class=\"green-text\">1.5<\/span>;\r\n} <\/span>\r\n<\/pre>\r\n<\/div>\r\nThis code styles all <span class=\"inline-code green-text\">&lt;h1&gt;<\/span> elements to be blue and have a font size of 24 pixels. It also increases the line spacing for <span class=\"inline-code green-text\">&lt;p&gt;<\/span> elements.\r\n<h3>CSS Key Concepts<\/h3>\r\n<strong>Selectors:<\/strong> Target specific elements (e.g., <span class=\"inline-code blue-text\">h1<\/span>, <span class=\"inline-code blue-text\">p<\/span>, <span class=\"inline-code blue-text\">.class<\/span>, <span class=\"inline-code blue-text\">#id<\/span>).\r\n\r\n<strong>Properties and Values:<\/strong> Define the styles (e.g., <span class=\"inline-code black-text\">colour: <span class=\"blue-text\">red<\/span>;<\/span>, <span class=\"inline-code black-text\">margin: <span class=\"green-text\">10px<\/span>;<\/span>).\r\n\r\n<strong>Classes and IDs:<\/strong> Use <span class=\"inline-code blue-text\">.class<\/span> and <span class=\"inline-code blue-text\">#id<\/span> to apply styles to specific elements.\r\n<h3>Common CSS Properties<\/h3>\r\n<strong>Text:<\/strong> <span class=\"inline-code black-text\">colour<\/span>, <span class=\"inline-code black-text\">font-size<\/span>, <span class=\"inline-code black-text\">font-family<\/span>\r\n\r\n<strong>Spacing:<\/strong> <span class=\"inline-code black-text\">margin<\/span>, <span class=\"inline-code black-text\">padding<\/span>, <span class=\"inline-code black-text\">line-height<\/span>\r\n\r\n<strong>Borders:<\/strong> <span class=\"inline-code black-text\">border<\/span>, <span class=\"inline-code black-text\">border-radius<\/span>\r\n\r\n<strong>Layout:<\/strong> <span class=\"inline-code black-text\">display<\/span>, <span class=\"inline-code black-text\">flex<\/span>, <span class=\"inline-code black-text\">grid<\/span>\r\n<h3>CSS Exercise<\/h3>\r\nNavigate to Appearance &gt;&gt; Custom Styles in your Pressbooks dashboard. Try adding a simple CSS rule in the \"Your Styles\" section, such as changing the font size of headings:\r\n<div class=\"code-textbox-outer\">\r\n<pre class=\"code-textbox-title\">  CSS:\r\n<\/pre>\r\n<pre class=\"code-textbox-inner\"><span class=\"black-text\"><span class=\"blue-text\">h1<\/span> {\r\n  font-size: <span class=\"green-text\">30px<\/span>;\r\n}<\/span>\r\n<\/pre>\r\n<\/div>\r\n<strong>Note:\u00a0<\/strong>These two lines of code will change the font size of all <span class=\"inline-code blue-text\">h1<\/span> elements in your textbook. Explore <span class=\"inline-code green-text\">&lt;div&gt;<\/span> and <span class=\"inline-code blue-text\">.class<\/span> if you want to learn how to apply these changes to selected parts.\r\n\r\n<hr \/>\r\n\r\n<div class=\"textbox textbox--key-takeaways\"><header class=\"textbox__header\">\r\n<h2 class=\"textbox__title\">Additional Resources<\/h2>\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n<ul>\r\n \t<li><a href=\"https:\/\/www.w3schools.com\/html\/default.asp\" target=\"_blank\" rel=\"noopener\">HTML Tutorials<\/a> by W3Schools<\/li>\r\n \t<li><a href=\"https:\/\/www.w3schools.com\/css\/default.asp\" target=\"_blank\" rel=\"noopener\">CSS Tutorials<\/a> by W3Schools<\/li>\r\n \t<li><a href=\"https:\/\/iu.pressbooks.pub\/htmlcssbasics\/\" target=\"_blank\" rel=\"noopener\">HTML &amp; CSS Basics for Digital Writers<\/a> by Cate Deventer, Indiana University Pressbooks<\/li>\r\n \t<li>Although there are many other resources available online for HTML and CSS, most of them are focused on web pages. Please be sure to understand how these features would work in Pressbooks, as there are many subtle differences between using them in Pressbooks and on web pages.<\/li>\r\n<\/ul>\r\n<\/div>\r\n<\/div>\r\n<div class=\"textbox textbox--learning-objectives\">\r\n<div class=\"textbox__content\">Considering modifying the default theme beyond the theme options provided as part of your Pressbooks project with Concordia University Library? If so, please include your intentions to customize the Cascading Style Sheets (CSS) in the project plan for your open textbook or open guidebook. We additionally recommend creating a <a href=\"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/chapter\/design-appendix\/\">design plan<\/a>.<\/div>\r\n<\/div>","rendered":"<div class=\"textbox outer\">\n<h2>Basics of HTML and CSS in<\/h2>\n<div class=\"textbox inner\">\n<h2>Pressbooks<\/h2>\n<\/div>\n<p>HTML structures web content, while CSS styles it. Together, they control how your textbook looks and feels.<\/p>\n<\/div>\n<p>Pressbooks uses both HTML (HyperText Markup Language) and CSS (Cascading Style Sheets) behind the scenes. Understanding how markup language and style sheets function together will help you grasp foundational web design parameters and accessibility principles. The following basics may be of interest to those working with preset themes, but they are essential for anyone attempting to customize their book.<\/p>\n<div class=\"menu-table-wrapper h5p-display\" style=\"flex-direction: column;\">\n<span class=\"menu-table-title\">Basics of<\/span><\/p>\n<div class=\"menu-table\" style=\"flex-direction: row;\"><a class=\"menu-table-panel html-css-panel\" href=\"#html\">HTML<br \/>\n<span style=\"font-size: 0.6em;\">(HyperText Markup Language)<\/span><\/a><br \/>\n<a class=\"menu-table-panel html-css-panel\" href=\"#css\">CSS<br \/>\n<span style=\"font-size: 0.6em;\">(Cascading Style Sheets)<\/span><\/a><\/div>\n<\/div>\n<h2><a id=\"html\"><\/a>HTML (HyperText Markup Language)<\/h2>\n<p>HTML is the language used to structure content on the web. It consists of elements (or &#8220;tags&#8221;) that define different parts of your content, such as headings, paragraphs, lists, and links.<\/p>\n<p>For example:<\/p>\n<div class=\"code-textbox-outer\">\n<pre class=\"code-textbox-title\">  HTML:\r\n<\/pre>\n<pre class=\"code-textbox-inner\">&lt;h1&gt; <span class=\"black-text\">This is a Heading<\/span> &lt;\/h1&gt;\r\n&lt;p&gt; <span class=\"black-text\">This is a paragraph of text.<\/span> &lt;\/p&gt;\r\n  \r\n&lt;ul&gt;\r\n  &lt;li&gt; <span class=\"black-text\">First item<\/span> &lt;\/li&gt;\r\n  &lt;li&gt; <span class=\"black-text\">Second item<\/span> &lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<\/div>\n<h3>HTML Key Elements to Know<\/h3>\n<p><strong>Headings:<\/strong> Structure your text into hierarchical levels (e.g. <span class=\"inline-code green-text\">&lt;h1&gt;<\/span>, <span class=\"inline-code green-text\">&lt;h2&gt;<\/span>).<\/p>\n<p><strong>Paragraphs:<\/strong> Use <span class=\"inline-code green-text\">&lt;p&gt;<\/span> for blocks of text.<\/p>\n<p><strong>Lists:<\/strong> Organize items using ordered <span class=\"inline-code green-text\">&lt;ol&gt;<\/span> or unordered <span class=\"inline-code green-text\">&lt;ul&gt;<\/span> lists.<\/p>\n<p><strong>Links:<\/strong> Create hyperlinks with the <span class=\"inline-code green-text\">&lt;a&gt;<\/span> tag (e.g. <span class=\"inline-code green-text\">&lt;a <span class=\"red-text\">href<\/span><span class=\"blue-text\">=&#8221;https:\/\/link.com&#8221;<\/span>&gt;<span class=\"black-text\"> Link <\/span>&lt;\/a&gt;<\/span>).<\/p>\n<p><strong>Images:<\/strong> Add visuals with the <span class=\"inline-code green-text\">&lt;img&gt;<\/span> tag (e.g. <span class=\"inline-code green-text\">&lt;img <span class=\"red-text\">src<\/span><span class=\"blue-text\">=&#8221;image.jpg&#8221;<\/span> <span class=\"red-text\">alt<\/span><span class=\"blue-text\">=&#8221;Description&#8221;<\/span>&gt;<\/span>).<\/p>\n<h3>HTML Exercise<\/h3>\n<p>Try to understand the HTML content in your Pressbooks project by clicking on the Text (HTML) tab in the Edit Part\/Chapter page. Take great caution when trying to change any of the HTML tags.<\/p>\n<hr \/>\n<h2><a id=\"css\"><\/a>CSS (Cascading Style Sheets)<\/h2>\n<p>CSS is the language used to style HTML content. It defines how elements look\u2014their colours, fonts, sizes, and layout. In Pressbooks, CSS customizations let you modify the visual appearance of your book.<\/p>\n<h3>How CSS Works<\/h3>\n<p>CSS uses &#8220;selectors&#8221; to target HTML elements and apply &#8220;rules&#8221; that style them.<\/p>\n<p>For example:<\/p>\n<div class=\"code-textbox-outer\">\n<pre class=\"code-textbox-title\">  CSS:\r\n<\/pre>\n<pre class=\"code-textbox-inner\"><span class=\"black-text\"><span class=\"blue-text\">h1<\/span> {\r\n  colour: <span class=\"blue-text\">blue<\/span>;\r\n  font-size: <span class=\"green-text\">24px<\/span>;\r\n}\r\n\r\n<span class=\"blue-text\">p<\/span> {\r\n  line-height: <span class=\"green-text\">1.5<\/span>;\r\n} <\/span>\r\n<\/pre>\n<\/div>\n<p>This code styles all <span class=\"inline-code green-text\">&lt;h1&gt;<\/span> elements to be blue and have a font size of 24 pixels. It also increases the line spacing for <span class=\"inline-code green-text\">&lt;p&gt;<\/span> elements.<\/p>\n<h3>CSS Key Concepts<\/h3>\n<p><strong>Selectors:<\/strong> Target specific elements (e.g., <span class=\"inline-code blue-text\">h1<\/span>, <span class=\"inline-code blue-text\">p<\/span>, <span class=\"inline-code blue-text\">.class<\/span>, <span class=\"inline-code blue-text\">#id<\/span>).<\/p>\n<p><strong>Properties and Values:<\/strong> Define the styles (e.g., <span class=\"inline-code black-text\">colour: <span class=\"blue-text\">red<\/span>;<\/span>, <span class=\"inline-code black-text\">margin: <span class=\"green-text\">10px<\/span>;<\/span>).<\/p>\n<p><strong>Classes and IDs:<\/strong> Use <span class=\"inline-code blue-text\">.class<\/span> and <span class=\"inline-code blue-text\">#id<\/span> to apply styles to specific elements.<\/p>\n<h3>Common CSS Properties<\/h3>\n<p><strong>Text:<\/strong> <span class=\"inline-code black-text\">colour<\/span>, <span class=\"inline-code black-text\">font-size<\/span>, <span class=\"inline-code black-text\">font-family<\/span><\/p>\n<p><strong>Spacing:<\/strong> <span class=\"inline-code black-text\">margin<\/span>, <span class=\"inline-code black-text\">padding<\/span>, <span class=\"inline-code black-text\">line-height<\/span><\/p>\n<p><strong>Borders:<\/strong> <span class=\"inline-code black-text\">border<\/span>, <span class=\"inline-code black-text\">border-radius<\/span><\/p>\n<p><strong>Layout:<\/strong> <span class=\"inline-code black-text\">display<\/span>, <span class=\"inline-code black-text\">flex<\/span>, <span class=\"inline-code black-text\">grid<\/span><\/p>\n<h3>CSS Exercise<\/h3>\n<p>Navigate to Appearance &gt;&gt; Custom Styles in your Pressbooks dashboard. Try adding a simple CSS rule in the &#8220;Your Styles&#8221; section, such as changing the font size of headings:<\/p>\n<div class=\"code-textbox-outer\">\n<pre class=\"code-textbox-title\">  CSS:\r\n<\/pre>\n<pre class=\"code-textbox-inner\"><span class=\"black-text\"><span class=\"blue-text\">h1<\/span> {\r\n  font-size: <span class=\"green-text\">30px<\/span>;\r\n}<\/span>\r\n<\/pre>\n<\/div>\n<p><strong>Note:\u00a0<\/strong>These two lines of code will change the font size of all <span class=\"inline-code blue-text\">h1<\/span> elements in your textbook. Explore <span class=\"inline-code green-text\">&lt;div&gt;<\/span> and <span class=\"inline-code blue-text\">.class<\/span> if you want to learn how to apply these changes to selected parts.<\/p>\n<hr \/>\n<div class=\"textbox textbox--key-takeaways\">\n<header class=\"textbox__header\">\n<h2 class=\"textbox__title\">Additional Resources<\/h2>\n<\/header>\n<div class=\"textbox__content\">\n<ul>\n<li><a href=\"https:\/\/www.w3schools.com\/html\/default.asp\" target=\"_blank\" rel=\"noopener\">HTML Tutorials<\/a> by W3Schools<\/li>\n<li><a href=\"https:\/\/www.w3schools.com\/css\/default.asp\" target=\"_blank\" rel=\"noopener\">CSS Tutorials<\/a> by W3Schools<\/li>\n<li><a href=\"https:\/\/iu.pressbooks.pub\/htmlcssbasics\/\" target=\"_blank\" rel=\"noopener\">HTML &amp; CSS Basics for Digital Writers<\/a> by Cate Deventer, Indiana University Pressbooks<\/li>\n<li>Although there are many other resources available online for HTML and CSS, most of them are focused on web pages. Please be sure to understand how these features would work in Pressbooks, as there are many subtle differences between using them in Pressbooks and on web pages.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"textbox textbox--learning-objectives\">\n<div class=\"textbox__content\">Considering modifying the default theme beyond the theme options provided as part of your Pressbooks project with Concordia University Library? If so, please include your intentions to customize the Cascading Style Sheets (CSS) in the project plan for your open textbook or open guidebook. We additionally recommend creating a <a href=\"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/chapter\/design-appendix\/\">design plan<\/a>.<\/div>\n<\/div>\n","protected":false},"author":1,"menu_order":1,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[48],"contributor":[],"license":[],"class_list":["post-5640","chapter","type-chapter","status-publish","hentry","chapter-type-numberless"],"part":4781,"_links":{"self":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters\/5640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":54,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters\/5640\/revisions"}],"predecessor-version":[{"id":6528,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters\/5640\/revisions\/6528"}],"part":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/parts\/4781"}],"metadata":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters\/5640\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/media?parent=5640"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapter-type?post=5640"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/contributor?post=5640"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/license?post=5640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}