{"id":3055,"date":"2025-04-05T19:46:14","date_gmt":"2025-04-05T23:46:14","guid":{"rendered":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/?post_type=chapter&#038;p=3055"},"modified":"2025-12-13T16:19:41","modified_gmt":"2025-12-13T21:19:41","slug":"accessible-css","status":"publish","type":"chapter","link":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/chapter\/accessible-css\/","title":{"raw":"Accessible CSS","rendered":"Accessible CSS"},"content":{"raw":"<div class=\"textbox outer\">\r\n<h2>Best CSS Accessibility Practices in<\/h2>\r\n<div class=\"textbox inner\">\r\n<h2>Pressbooks<\/h2>\r\n<\/div>\r\n<\/div>\r\nCascading Style Sheets (CSS) customize the look of HTML elements, such as changing the colour of text, positioning an element at a specific location on a page, or creating decorative elements like borders. When implementing these styles with multiple lines of customization, accessibility should always be a top priority. Although it is possible to write CSS directly into the HTML, writing the CSS into a separate file keeps the HTML page tidy and adheres to good design practices. Some of these practices include:\r\n<h3>Responsive Units<\/h3>\r\nA responsive website has elements that adjust to the screens of various devices, including phones, tablets, and laptops. Units such as <span class=\"inline-code green-text\">%<\/span>, <span class=\"inline-code green-text\">em<\/span>, and <span class=\"inline-code green-text\">rem<\/span> are considered responsive, while non-responsive units of measurement include <span class=\"inline-code green-text\">mm<\/span> , <span class=\"inline-code green-text\">cm<\/span> , <span class=\"inline-code green-text\">in<\/span> , <span class=\"inline-code green-text\">px<\/span> , and <span class=\"inline-code green-text\">pt<\/span>. When using non-responsive units, elements remain the same size across devices, which can cause layout issues with the content. For this reason, responsive units are recommended as they enable accessible design in CSS.\r\n<div class=\"h5p-display\" style=\"margin-top: 1.5em;\">[h5p id=\"70\"]<\/div>\r\n<div class=\"textbox textbox--accordion-export\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Text Elements<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">Units that are relative (not fixed in size) make elements responsive. When the text of an element is denoted by the unit \"em,\" a change in the parent element's font size will adjust the font size of all its child elements within that unit.Another responsive unit is \"rem,\" where \"r\" stands for root. Instead of adjusting to the parent element, \"rem\" adjusts to the HTML element and is relative to the default settings set by a user on their browser. If an individual has their browser set to a larger font (the default), rem adjusts relative to the size of that default.\r\n\r\nLastly, the % unit can be used to set font size relative to the default text size in your Pressbooks.\r\n\r\n<\/div>\r\n<\/div>\r\n<div class=\"textbox textbox--accordion-export\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Image Elements<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">Use the % unit to adjust the image element's size relative to the width and height of the device\u2019s screen.<\/div>\r\n<\/div>\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;div<span class=\"red-text\"> class<\/span><span class=\"blue-text\">=\"parent\"<\/span>&gt;\r\n  <span class=\"black-text\">Hello,<\/span>\r\n    &lt;div <span class=\"red-text\">class<\/span><span class=\"blue-text\">=\"child\"&gt;<\/span>\r\n      <span class=\"black-text\">World.<\/span>\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\r\n<\/div>\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 black-text\"><span class=\"blue-text\">.parent<\/span> {\r\n  font-size: <span class=\"green-text\">10px<\/span>;\r\n}\r\n\r\n<span class=\"blue-text\">.child<\/span> {\r\n  font-size: <span class=\"green-text\">0.5em<\/span>;\r\n}\r\n<\/pre>\r\n<\/div>\r\nAbove, the <span class=\"inline-code blue-text\">child<\/span> div is nested in the <span class=\"inline-code blue-text\">parent<\/span> div. With <span class=\"inline-code green-text\"><span class=\"black-text\">font-size:<\/span> 0.5em;<\/span>, it will assume a size half or equivalent to 5 pixels. If the value of the parent element is changed, the <span class=\"inline-code blue-text\">child<\/span> will adjust to assume a value half of the parent's.\r\n\r\nTo test these concepts to understand responsive design, visit the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn_web_development\/Core\/CSS_layout\/Responsive_Design\" target=\"_blank\" rel=\"noopener\">MDN Web Docs<\/a> website.\r\n<h3>Reusability of Code<\/h3>\r\nStandardization enables your code to be easily interpreted by different developers who may interact with your Pressbook to either edit directly or re-use it within the context of open education. Organized code also impacts the readers of your book in that visual cohesion and appropriate tagging of elements enable the content to be easily interpreted.\r\n\r\nStandardize repetitions within the CSS rather than using exceptional styles within your HTML, otherwise, the HTML code can become bulky. Notice the cluttered versus cleaned HTML highlighted in the two versions below.\r\n<div class=\"code-textbox-outer\">\r\n<pre class=\"code-textbox-title\" style=\"padding-left: 0.9em !important;\"><span class=\"wcag-standards-cross wcag-codebox-cross-margin\">HTML (Cluttered):<\/span><\/pre>\r\n<pre class=\"code-textbox-inner grey-text\">&lt;div <span class=\"red-text\">style=<\/span><span class=\"blue-text\">\"padding: 2.5em; margin: 0.9em 0 0.9em 0; font-family: \"Montserrat\", sans-serif; font-size: 1em; text-align: center; colour: darkgrey;\"<\/span>&gt;\r\n  &lt;h2&gt; An inspiring example of departmental collaboration at &lt;\/h2&gt;\r\n  &lt;div <span class=\"red-text\">style=<\/span><span class=\"blue-text\">\"padding: 2.5em; margin: 0.9em 0 0.9em 0; font-family: \"Montserrat\",\r\n  sans-serif; font-size: 1em; text-align: center; colour: black;\"<\/span>&gt;\r\n    &lt;h2&gt; Concordia &lt;\/h2&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\r\n<\/div>\r\n<div class=\"code-textbox-outer\">\r\n<pre class=\"code-textbox-title\" style=\"padding-left: 0.9em !important;\"><span class=\"wcag-standards-check wcag-codebox-check-margin\">HTML (Clean):<\/span><\/pre>\r\n<pre class=\"code-textbox-inner grey-text\">&lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox outer\"<\/span>&gt;\r\n  &lt;h2&gt; An inspiring example of departmental collaboration at &lt;\/h2&gt;\r\n  &lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox inner\"<\/span>&gt;\r\n    &lt;h2&gt; Concordia &lt;\/h2&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\r\n<\/div>\r\nTo keep your code organized and maintain readability, aim to group repeating properties in a class while setting unique properties in their own IDs. A class is infinitely repeatable, while an ID can only be present once within a page. Classes help standardize your code, ensuring that all instances of a particular element are consistent throughout the website or document, which also prevents clutter in the HTML. You can have two different classes with the CSS <span class=\"inline-code black-text\">colour: <span class=\"blue-text\">black;<\/span><\/span>. For 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=\"blue-text\">.textbox<\/span> <span class=\"black-text\">{\r\n  padding: <span class=\"green-text\">2.5em<\/span>;\r\n  margin: <span class=\"green-text\">0.9em 0 0.9em 0<\/span>;\r\n  font-family: <span class=\"red-text\">\"Montserrat\"<\/span>, <span class=\"blue-text\">sans-serif<\/span>;\r\n  font-size: <span class=\"green-text\">1em<\/span>;\r\n  text-align: <span class=\"blue-text\">center<\/span>;\r\n}<\/span>\r\n\r\n<span class=\"blue-text\">.outer<\/span> <span class=\"black-text\">{\r\n  colour: <span class=\"blue-text\">darkgrey<\/span>;\r\n}<\/span>\r\n\r\n<span class=\"blue-text\">.inner<\/span> <span class=\"black-text\">{\r\n  colour: <span class=\"blue-text\">black<\/span>;\r\n}<\/span>\r\n<\/pre>\r\n<\/div>\r\n<div class=\"code-textbox-outer\">\r\n<pre class=\"code-textbox-title\">  HTML:<\/pre>\r\n<pre class=\"code-textbox-inner\">&lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox outer\"<\/span><span class=\"green-text\">&gt;<\/span>\r\n  &lt;h2&gt; <span class=\"black-text\">An inspiring example of departmental collaboration at<\/span> &lt;\/h2&gt;\r\n  &lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox inner\"<\/span>&gt;\r\n    &lt;h2&gt; <span class=\"black-text\">Concordia<\/span> &lt;\/h2&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\r\n<\/div>\r\nObserve the relationship between the CSS and HTML code above. Notice how the <span class=\"inline-code blue-text\">textbox<\/span> class selector in the CSS is used in two <span class=\"inline-code green-text\">div<\/span> elements in the HTML. Additionally, styling unique to a specific element can be written into the second class, for instance, the colour. Note that each element attribute can have more than two classes (for example, the first <span class=\"inline-code green-text\">div<\/span> element in the HTML has the classes <span class=\"inline-code blue-text\">textbox<\/span> and <span class=\"inline-code blue-text\">outer<\/span>).\r\n<h3>Colour Contrast<\/h3>\r\nCertain colour combinations can make it challenging to interpret text; text and background colours should be distinct enough to be easily distinguished. For example, a light blue text on a white background generates a poor contrast ratio, making the words difficult to read.\r\n\r\nColour contrast is rated on a numerical ratio that translates to WCAG 2.0 letter grades; to follow best accessibility practices, we recommend following AA level standards.\r\n\r\nTools for verifying colour contrasts include the <a href=\"https:\/\/wave.webaim.org\/\" target=\"_blank\" rel=\"noopener\">WAVE Web Accessibility Evaluation Tools<\/a>, <a href=\"https:\/\/color.adobe.com\/create\/color-contrast-analyzer\" target=\"_blank\" rel=\"noopener\">Adobe Colour Tool<\/a>, the <a href=\"https:\/\/webaim.org\/resources\/contrastchecker\/\" target=\"_blank\" rel=\"noopener\">WebAIM Contrast Checker<\/a>, and the <a href=\"https:\/\/accessibleweb.com\/color-contrast-checker\/\" target=\"_blank\" rel=\"noopener\">Accessible Web WCAG Color Contrast Checker<\/a>.\r\n<div class=\"wcag-box h5p-display\">\r\n<div class=\"wcag-child\"><span class=\"wcag-text\" style=\"color: #bfe1ff;\">This is bad\r\ncolour contrast.<\/span>\r\n<div class=\"wcag-bottom-textbox\" style=\"left: 0;\">Contrast Ratio:\r\n1.36 : 1<\/div>\r\n<div class=\"wcag-bottom-textbox\" style=\"right: 0;\"><span class=\"wcag-standards-cross\"><span style=\"display: inline;\"><strong>Does not<\/strong> meet\r\nWCAG Standards<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"wcag-child\"><span class=\"wcag-text\" style=\"color: #862d3a;\">This is good\r\ncolour contrast.<\/span>\r\n<div class=\"wcag-bottom-textbox\" style=\"left: 0;\">Contrast Ratio:\r\n8.57 : 1<\/div>\r\n<div class=\"wcag-bottom-textbox\" style=\"right: 0;\"><span class=\"wcag-standards-check\"><span style=\"display: inline;\"><strong>Does<\/strong> meet\r\nWCAG Standards<\/span><\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<h3>Line Height<\/h3>\r\nLines of text displayed too closely may make it challenging to distinguish rows of words. You can solve this by implementing the <span class=\"inline-code black-text\">line-height<\/span> property in the parent container of your text. The property increases the space between lines of words and takes a value of any size units (e.g. <span class=\"inline-code green-text\">px<\/span>, <span class=\"inline-code green-text\">em<\/span>, <span class=\"inline-code green-text\">%<\/span>, etc.)\r\n<div class=\"lheight-box h5p-display\">\r\n<div class=\"lheight-child\">\r\n\r\n<span class=\"lheight-text\" style=\"line-height: 18px;\">This text has a line-height property set to 18px. Notice how the space between each line of text is small, making it difficult to read.<\/span>\r\n<div class=\"lheight-bottom-textbox\" style=\"width: 100%;\"><span class=\"wcag-standards-cross wcag-margin\"><strong>Does not\u00a0<\/strong> follow accessibility practices<\/span><\/div>\r\n<\/div>\r\n<div class=\"lheight-child\">\r\n\r\n<span class=\"lheight-text\" style=\"top: 1.9em;\">This text has a line-height property set to 30px. Notice how the space between each line of text is large, making it easier to read.<\/span>\r\n<div class=\"lheight-bottom-textbox\" style=\"width: 100%;\"><span class=\"wcag-standards-check wcag-margin\"><strong>Does\u00a0<\/strong> follow good accessibility practices<\/span><\/div>\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.\u00a0We 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>Best CSS Accessibility Practices in<\/h2>\n<div class=\"textbox inner\">\n<h2>Pressbooks<\/h2>\n<\/div>\n<\/div>\n<p>Cascading Style Sheets (CSS) customize the look of HTML elements, such as changing the colour of text, positioning an element at a specific location on a page, or creating decorative elements like borders. When implementing these styles with multiple lines of customization, accessibility should always be a top priority. Although it is possible to write CSS directly into the HTML, writing the CSS into a separate file keeps the HTML page tidy and adheres to good design practices. Some of these practices include:<\/p>\n<h3>Responsive Units<\/h3>\n<p>A responsive website has elements that adjust to the screens of various devices, including phones, tablets, and laptops. Units such as <span class=\"inline-code green-text\">%<\/span>, <span class=\"inline-code green-text\">em<\/span>, and <span class=\"inline-code green-text\">rem<\/span> are considered responsive, while non-responsive units of measurement include <span class=\"inline-code green-text\">mm<\/span> , <span class=\"inline-code green-text\">cm<\/span> , <span class=\"inline-code green-text\">in<\/span> , <span class=\"inline-code green-text\">px<\/span> , and <span class=\"inline-code green-text\">pt<\/span>. When using non-responsive units, elements remain the same size across devices, which can cause layout issues with the content. For this reason, responsive units are recommended as they enable accessible design in CSS.<\/p>\n<div class=\"h5p-display\" style=\"margin-top: 1.5em;\">\n<div id=\"h5p-70\">\n<div class=\"h5p-iframe-wrapper\"><iframe id=\"h5p-iframe-70\" class=\"h5p-iframe\" data-content-id=\"70\" style=\"height:1px\" src=\"about:blank\" frameBorder=\"0\" scrolling=\"no\" title=\"Accessible CSS - Responsiveness\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<div class=\"textbox textbox--accordion-export\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Text Elements<\/p>\n<\/header>\n<div class=\"textbox__content\">Units that are relative (not fixed in size) make elements responsive. When the text of an element is denoted by the unit &#8220;em,&#8221; a change in the parent element&#8217;s font size will adjust the font size of all its child elements within that unit.Another responsive unit is &#8220;rem,&#8221; where &#8220;r&#8221; stands for root. Instead of adjusting to the parent element, &#8220;rem&#8221; adjusts to the HTML element and is relative to the default settings set by a user on their browser. If an individual has their browser set to a larger font (the default), rem adjusts relative to the size of that default.<\/p>\n<p>Lastly, the % unit can be used to set font size relative to the default text size in your Pressbooks.<\/p>\n<\/div>\n<\/div>\n<div class=\"textbox textbox--accordion-export\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Image Elements<\/p>\n<\/header>\n<div class=\"textbox__content\">Use the % unit to adjust the image element&#8217;s size relative to the width and height of the device\u2019s screen.<\/div>\n<\/div>\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;div<span class=\"red-text\"> class<\/span><span class=\"blue-text\">=\"parent\"<\/span>&gt;\r\n  <span class=\"black-text\">Hello,<\/span>\r\n    &lt;div <span class=\"red-text\">class<\/span><span class=\"blue-text\">=\"child\"&gt;<\/span>\r\n      <span class=\"black-text\">World.<\/span>\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<\/div>\n<div class=\"code-textbox-outer\">\n<pre class=\"code-textbox-title\">  CSS:\r\n<\/pre>\n<pre class=\"code-textbox-inner black-text\"><span class=\"blue-text\">.parent<\/span> {\r\n  font-size: <span class=\"green-text\">10px<\/span>;\r\n}\r\n\r\n<span class=\"blue-text\">.child<\/span> {\r\n  font-size: <span class=\"green-text\">0.5em<\/span>;\r\n}\r\n<\/pre>\n<\/div>\n<p>Above, the <span class=\"inline-code blue-text\">child<\/span> div is nested in the <span class=\"inline-code blue-text\">parent<\/span> div. With <span class=\"inline-code green-text\"><span class=\"black-text\">font-size:<\/span> 0.5em;<\/span>, it will assume a size half or equivalent to 5 pixels. If the value of the parent element is changed, the <span class=\"inline-code blue-text\">child<\/span> will adjust to assume a value half of the parent&#8217;s.<\/p>\n<p>To test these concepts to understand responsive design, visit the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn_web_development\/Core\/CSS_layout\/Responsive_Design\" target=\"_blank\" rel=\"noopener\">MDN Web Docs<\/a> website.<\/p>\n<h3>Reusability of Code<\/h3>\n<p>Standardization enables your code to be easily interpreted by different developers who may interact with your Pressbook to either edit directly or re-use it within the context of open education. Organized code also impacts the readers of your book in that visual cohesion and appropriate tagging of elements enable the content to be easily interpreted.<\/p>\n<p>Standardize repetitions within the CSS rather than using exceptional styles within your HTML, otherwise, the HTML code can become bulky. Notice the cluttered versus cleaned HTML highlighted in the two versions below.<\/p>\n<div class=\"code-textbox-outer\">\n<pre class=\"code-textbox-title\" style=\"padding-left: 0.9em !important;\"><span class=\"wcag-standards-cross wcag-codebox-cross-margin\">HTML (Cluttered):<\/span><\/pre>\n<pre class=\"code-textbox-inner grey-text\">&lt;div <span class=\"red-text\">style=<\/span><span class=\"blue-text\">\"padding: 2.5em; margin: 0.9em 0 0.9em 0; font-family: \"Montserrat\", sans-serif; font-size: 1em; text-align: center; colour: darkgrey;\"<\/span>&gt;\r\n  &lt;h2&gt; An inspiring example of departmental collaboration at &lt;\/h2&gt;\r\n  &lt;div <span class=\"red-text\">style=<\/span><span class=\"blue-text\">\"padding: 2.5em; margin: 0.9em 0 0.9em 0; font-family: \"Montserrat\",\r\n  sans-serif; font-size: 1em; text-align: center; colour: black;\"<\/span>&gt;\r\n    &lt;h2&gt; Concordia &lt;\/h2&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<\/div>\n<div class=\"code-textbox-outer\">\n<pre class=\"code-textbox-title\" style=\"padding-left: 0.9em !important;\"><span class=\"wcag-standards-check wcag-codebox-check-margin\">HTML (Clean):<\/span><\/pre>\n<pre class=\"code-textbox-inner grey-text\">&lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox outer\"<\/span>&gt;\r\n  &lt;h2&gt; An inspiring example of departmental collaboration at &lt;\/h2&gt;\r\n  &lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox inner\"<\/span>&gt;\r\n    &lt;h2&gt; Concordia &lt;\/h2&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<\/div>\n<p>To keep your code organized and maintain readability, aim to group repeating properties in a class while setting unique properties in their own IDs. A class is infinitely repeatable, while an ID can only be present once within a page. Classes help standardize your code, ensuring that all instances of a particular element are consistent throughout the website or document, which also prevents clutter in the HTML. You can have two different classes with the CSS <span class=\"inline-code black-text\">colour: <span class=\"blue-text\">black;<\/span><\/span>. 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=\"blue-text\">.textbox<\/span> <span class=\"black-text\">{\r\n  padding: <span class=\"green-text\">2.5em<\/span>;\r\n  margin: <span class=\"green-text\">0.9em 0 0.9em 0<\/span>;\r\n  font-family: <span class=\"red-text\">\"Montserrat\"<\/span>, <span class=\"blue-text\">sans-serif<\/span>;\r\n  font-size: <span class=\"green-text\">1em<\/span>;\r\n  text-align: <span class=\"blue-text\">center<\/span>;\r\n}<\/span>\r\n\r\n<span class=\"blue-text\">.outer<\/span> <span class=\"black-text\">{\r\n  colour: <span class=\"blue-text\">darkgrey<\/span>;\r\n}<\/span>\r\n\r\n<span class=\"blue-text\">.inner<\/span> <span class=\"black-text\">{\r\n  colour: <span class=\"blue-text\">black<\/span>;\r\n}<\/span>\r\n<\/pre>\n<\/div>\n<div class=\"code-textbox-outer\">\n<pre class=\"code-textbox-title\">  HTML:<\/pre>\n<pre class=\"code-textbox-inner\">&lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox outer\"<\/span><span class=\"green-text\">&gt;<\/span>\r\n  &lt;h2&gt; <span class=\"black-text\">An inspiring example of departmental collaboration at<\/span> &lt;\/h2&gt;\r\n  &lt;div <span class=\"red-text\">class=<\/span><span class=\"blue-text\">\"textbox inner\"<\/span>&gt;\r\n    &lt;h2&gt; <span class=\"black-text\">Concordia<\/span> &lt;\/h2&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<\/div>\n<p>Observe the relationship between the CSS and HTML code above. Notice how the <span class=\"inline-code blue-text\">textbox<\/span> class selector in the CSS is used in two <span class=\"inline-code green-text\">div<\/span> elements in the HTML. Additionally, styling unique to a specific element can be written into the second class, for instance, the colour. Note that each element attribute can have more than two classes (for example, the first <span class=\"inline-code green-text\">div<\/span> element in the HTML has the classes <span class=\"inline-code blue-text\">textbox<\/span> and <span class=\"inline-code blue-text\">outer<\/span>).<\/p>\n<h3>Colour Contrast<\/h3>\n<p>Certain colour combinations can make it challenging to interpret text; text and background colours should be distinct enough to be easily distinguished. For example, a light blue text on a white background generates a poor contrast ratio, making the words difficult to read.<\/p>\n<p>Colour contrast is rated on a numerical ratio that translates to WCAG 2.0 letter grades; to follow best accessibility practices, we recommend following AA level standards.<\/p>\n<p>Tools for verifying colour contrasts include the <a href=\"https:\/\/wave.webaim.org\/\" target=\"_blank\" rel=\"noopener\">WAVE Web Accessibility Evaluation Tools<\/a>, <a href=\"https:\/\/color.adobe.com\/create\/color-contrast-analyzer\" target=\"_blank\" rel=\"noopener\">Adobe Colour Tool<\/a>, the <a href=\"https:\/\/webaim.org\/resources\/contrastchecker\/\" target=\"_blank\" rel=\"noopener\">WebAIM Contrast Checker<\/a>, and the <a href=\"https:\/\/accessibleweb.com\/color-contrast-checker\/\" target=\"_blank\" rel=\"noopener\">Accessible Web WCAG Color Contrast Checker<\/a>.<\/p>\n<div class=\"wcag-box h5p-display\">\n<div class=\"wcag-child\"><span class=\"wcag-text\" style=\"color: #bfe1ff;\">This is bad<br \/>\ncolour contrast.<\/span><\/p>\n<div class=\"wcag-bottom-textbox\" style=\"left: 0;\">Contrast Ratio:<br \/>\n1.36 : 1<\/div>\n<div class=\"wcag-bottom-textbox\" style=\"right: 0;\"><span class=\"wcag-standards-cross\"><span style=\"display: inline;\"><strong>Does not<\/strong> meet<br \/>\nWCAG Standards<\/span><\/span><\/div>\n<\/div>\n<div class=\"wcag-child\"><span class=\"wcag-text\" style=\"color: #862d3a;\">This is good<br \/>\ncolour contrast.<\/span><\/p>\n<div class=\"wcag-bottom-textbox\" style=\"left: 0;\">Contrast Ratio:<br \/>\n8.57 : 1<\/div>\n<div class=\"wcag-bottom-textbox\" style=\"right: 0;\"><span class=\"wcag-standards-check\"><span style=\"display: inline;\"><strong>Does<\/strong> meet<br \/>\nWCAG Standards<\/span><\/span><\/div>\n<\/div>\n<\/div>\n<h3>Line Height<\/h3>\n<p>Lines of text displayed too closely may make it challenging to distinguish rows of words. You can solve this by implementing the <span class=\"inline-code black-text\">line-height<\/span> property in the parent container of your text. The property increases the space between lines of words and takes a value of any size units (e.g. <span class=\"inline-code green-text\">px<\/span>, <span class=\"inline-code green-text\">em<\/span>, <span class=\"inline-code green-text\">%<\/span>, etc.)<\/p>\n<div class=\"lheight-box h5p-display\">\n<div class=\"lheight-child\">\n<p><span class=\"lheight-text\" style=\"line-height: 18px;\">This text has a line-height property set to 18px. Notice how the space between each line of text is small, making it difficult to read.<\/span><\/p>\n<div class=\"lheight-bottom-textbox\" style=\"width: 100%;\"><span class=\"wcag-standards-cross wcag-margin\"><strong>Does not\u00a0<\/strong> follow accessibility practices<\/span><\/div>\n<\/div>\n<div class=\"lheight-child\">\n<p><span class=\"lheight-text\" style=\"top: 1.9em;\">This text has a line-height property set to 30px. Notice how the space between each line of text is large, making it easier to read.<\/span><\/p>\n<div class=\"lheight-bottom-textbox\" style=\"width: 100%;\"><span class=\"wcag-standards-check wcag-margin\"><strong>Does\u00a0<\/strong> follow good accessibility practices<\/span><\/div>\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.\u00a0We additionally recommend creating a <a href=\"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/chapter\/design-appendix\/\">design plan<\/a>.<\/div>\n<\/div>\n","protected":false},"author":94,"menu_order":3,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[48],"contributor":[],"license":[],"class_list":["post-3055","chapter","type-chapter","status-publish","hentry","chapter-type-numberless"],"part":4781,"_links":{"self":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters\/3055","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\/94"}],"version-history":[{"count":319,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters\/3055\/revisions"}],"predecessor-version":[{"id":6569,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapters\/3055\/revisions\/6569"}],"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\/3055\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/media?parent=3055"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/pressbooks\/v2\/chapter-type?post=3055"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/contributor?post=3055"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/opentextbooks.concordia.ca\/pressbooksuserguide\/wp-json\/wp\/v2\/license?post=3055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}