{"id":110,"date":"2017-04-21T19:14:08","date_gmt":"2017-04-21T19:14:08","guid":{"rendered":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/chapter\/chapter-20-layout-formatting\/"},"modified":"2019-06-13T18:16:57","modified_gmt":"2019-06-13T18:16:57","slug":"chapter-20-layout-formatting","status":"publish","type":"chapter","link":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/chapter\/chapter-20-layout-formatting\/","title":{"raw":"Chapter 20: Layout Formatting","rendered":"Chapter 20: Layout Formatting"},"content":{"raw":"<h1 class=\"ChapterNumber\">\u00a0Box Model<\/h1>\r\n[caption id=\"\" align=\"aligncenter\" width=\"542\"]<img src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191348\/Boxmodell-detail_fmt.gif\" alt=\"A CSS Box Model\" width=\"542\" height=\"440\" \/> <a href=\"http:\/\/commons.wikimedia.org\/wiki\/File:Boxmodell-detail.gif\">By Matthias Apsel [CC0]<\/a>, via Wikimedia Commons. Figure 24 CSS Box Model[\/caption]\r\n<h1>Borders<\/h1>\r\n<p class=\"BodyFirst\">To better identify where our content falls on a page, and to signify that it is different from the material around it, we can adjust the borders on our elements. Borders can be enabled or disabled by the top, bottom, left and right of the element and can also have different styles like solid, double, grooved, dotted and dashed lines, among others.<\/p>\r\nTo specify a full border, we simply use border, and can apply color, width, and style:\r\n<table id=\"table-25\" class=\"blank\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<pre>&lt;style&gt;\r\n\r\np.one {\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n}\r\n\r\np.two {\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n}\r\n\r\np.three {\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n}\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\r\n<\/td>\r\n<td><a href=\"https:\/\/milnepublishing.geneseo.edu\/themissinglink\/wp-content\/uploads\/sites\/4\/2015\/07\/Chap20_Margins1_fmt.png\"><img class=\"alignnone wp-image-81 size-full\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191349\/Chap20_Margins1_fmt.png\" alt=\"Borders over text created via code.\" width=\"250\" height=\"128\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nThe full list of possible border styles is as follows:\r\n<p class=\"Caption\"><em><a>Table 4 Border Styles<\/a><\/em><\/p>\r\n\r\n<table id=\"table-26\" class=\"Table-1\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<th>\r\n<p class=\"Table-Heading\">Value<\/p>\r\n<\/th>\r\n<th>\r\n<p class=\"Table-Heading\">Description<\/p>\r\n<\/th>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Small\">none<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">No border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Small\">dotted<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Dotted border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Small\">dashed<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Dashed border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Small\">solid<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Solid border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Small\">double<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Double (two lines) border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Small\">groove<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Grooved, 3d border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Small\">ridge<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Ridged, 3d border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Small\">inset<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Lowered (sunken) 3d border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Small\">outset<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Raised 3d border.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Small\">inherit<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Small\">Inherits the same style as the parent element.<\/p>\r\n<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<h1>Margin and Padding<\/h1>\r\nThese related concepts allow you to control the amount of space between your content and its container, and between the container and objects around it. Padding controls the amount of space inside your container, for instance between text and a set of paragraph tags. You can remember padding as the inside by thinking about a padded room; the padding is only effective if it is on the inside of the walls.\r\n\r\nBy adding borders to our paragraphs as we did above, we can see the outline of where the paragraph fits into our page. Now, we will see the difference when we apply padding:\r\n<table id=\"table-27\" class=\"blank\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {padding:10px;}<\/strong><\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\r\n<\/td>\r\n<td><img class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191350\/chap20_margins_fmt.png\" alt=\"Padding added to borders around text via coding.\" width=\"262\" height=\"190\" \/><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nYou will notice that the paragraphs still have not moved relative to one another, they each simply take up more space. In order to move them further away from each other, we can add a margin:\r\n<table id=\"table-28\" class=\"blank\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {padding:10px;}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {margin:50px;}<\/strong><\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\r\n<\/td>\r\n<td>\r\n<p class=\"Centered\"><img class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191351\/chap20_margins2_fmt.png\" alt=\"Margins added to border created via coding.\" width=\"278\" height=\"263\" \/><\/p>\r\n<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nWith both examples, we can adjust our values by pixel or percent. We can also control the amount of change by each side of the object, by specifying top, bottom, left or right to our rules. To do this we need to edit our values to only pad the left side of our paragraphs, and only apply a margin to the bottom of each:\r\n<table id=\"table-29\" class=\"blank\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three{<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {padding-left:10px;}<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {margin-bottom:50px;}<\/strong><\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\r\n<\/td>\r\n<td><img src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191353\/chap20_margins3_fmt.png\" alt=\"chap20_margins3.png\" \/><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nInstead of writing out multiple rules to adjust sides, we can combine them into one declaration by writing out our values clockwise, starting with top, as padding: top right bottom left or margin: top right bottom left, replacing the words with a fixed or relative value (they can be mixed) and by using zero as a place holder if we do not want the value changed from default:\r\n<table id=\"table-30\" class=\"blank\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\"><span class=\"Inline-Code\">}<\/span><\/span>\r\n\r\n<span class=\"CodeIndent1\"><span class=\"Inline-Code\">p.<\/span>two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {padding:50px 30px 50px 5px;}<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">p {margin:50px;}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\r\n<\/td>\r\n<td><img class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191354\/chap20_margins4_fmt.png\" alt=\"Text boxes with borders where the padding is being mixed around via coding\" width=\"270\" height=\"426\" \/><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<h1><a id=\"Background\"><\/a>Background<\/h1>\r\nThere is a lot we can do with the background of our pages. Colors and images can be applied to all or portions of our content, helping to highlight different elements of our site, and play a large part in the overall look and feel. We can specify colors by their name if they are a basic color like red, white, blue etc. or we can provide its hex value, or the values for its red, green, and blue values.\r\n<table id=\"table-31\" class=\"blank\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">Background-color: green;<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">Background-color:#ff3355;<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background-color: rgb(33,66,99);<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {padding:50px 30px 50px 5px;}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {margin:50px;}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\r\n<\/td>\r\n<td><img class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191356\/chap20_background_fmt.png\" alt=\"Text boxes filled with color via coding\" width=\"272\" height=\"427\" \/><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nTo use images instead of colors, we can specify the image\u2019s location in our files, and can also dictate where we want to place it on our page, whether or not it should repeat, and whether it should move or remain in place when the user scrolls the page. By default, images will repeat to fill the space they are placed in. To prevent this, we can add a no-repeat attribute to our definitions. This time, we will use the background attribute as opposed to the background-color attribute. The benefit of this is that you can include both in a set of rules on the same object (image first, color second), allowing you to have an image on top of a background color. Take note that in these examples, you will need to select your own images in place of those used below.\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background:url(clouds.jpg);<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent2\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background:url(calendar.jpg) no-repeat;<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent2\">background-color:#ff3355;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background:url(calendar.jpg);<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {padding:50px 30px 50px 5px;}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {margin:50px;}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\r\n<p class=\"BodyFirst\"><img class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191358\/chap20_background2_fmt.png\" alt=\"Textboxes with backgrounds inserted via coding\" width=\"279\" height=\"434\" \/><\/p>\r\nThere are two ways of achieving this affect. The first is by using advanced styling through CSS using <span class=\"Hyperlink\">WebKit<\/span> features supported by some browsers, and then adding style rules to create the effect as close as possible in other browsers. The second is by creating a repeatable gradient image. The first approach\u2019s reliance on WebKit provides support for Apple and Google products. For browsers that do not use WebKit, we have to add extra rules to achieve the same effect. This is a more advanced example as it requires knowledge of each browser\u2019s needs to create:\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">#ourBackground {<\/span>\r\n\r\n<span class=\"CodeIndent2\">background-color: #1a82f7;<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: url(ourFallBackImage.png);<\/span>\r\n\r\n<span class=\"CodeIndent2\">background-repeat: repeat-x;<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Safari 4-5, Chrome 1-9 *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727));<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Safari 5.1, Chrome 10+ *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -webkit-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Firefox 3.6+ *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -moz-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* IE 10 *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -ms-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Opera 11.10+ *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -o-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;div id=\"ourBackground\" width=\"300px\" height=\"300px\"&gt;\r\n\r\n<span class=\"CodeIndent1\">&lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">Some &lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">Text &lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">Here &lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;br\/&gt;<\/span>\r\n\r\n&lt;\/div&gt;<\/pre>\r\nThis code should produce an almost identical image in every browser, depending on which rule(s) the browser is able to execute:\r\n\r\n<span class=\"Picture-4\"><img class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191359\/chap20_background3_fmt.png\" alt=\"A text box with a blue background created via code.\" width=\"274\" height=\"113\" \/><\/span>\r\n\r\nThe first three lines of this style script\u2014\r\n<pre>background-color: #1a82f7;\r\n\r\nbackground: url(ourFallBackImage.png);\r\n\r\nbackground-repeat: repeat-x;<\/pre>\r\ndemonstrate how we create the gradient effect through an image. In this example, ourFallBackImage.png would be a very skinny (1 pixel) wide image as tall as we want our gradient to be. By repeating this image across the X axis (moving horizontally) the image will fill the width of the parent object. By specifying the bottom-most pixel color from our image as the background, the gradient will appear to fill the page. The balance of our rules in this example achieve the same result through CSS, but also provides more control over the gradient without needing to create additional images.\r\n<h1>Float<\/h1>\r\nFloating an object with CSS allows us to move it around within its parent object, ignoring (to some extent) the other items near it. Note that float is only for left\/right values, not top\/bottom, even though their movement may feel that way as windows resize.\r\n\r\nWhen multiple objects in the same container have the same float style, they will line up next to each other for as many as the container can fit. While this may sound confusing, we will look at it without the terminology: If you have a big box, and that box has small boxes in it, those boxes will fit as many of themselves left-to-right in a row as they can. Any boxes that do not fit will start a new \u201crow\u201d underneath.\r\n\r\nThe use of float is a big help to responsive styling. Boxes of content that normally fit side by side on a larger screen will automatically create more \u201crows,\u201d with less items in each, to accommodate screens with less width. Create a page with the following code, and then play around with the size of your browser window to see the resizing in action:\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">.thumbnail {<\/span>\r\n\r\n<span class=\"CodeIndent2\">float:left;<\/span>\r\n\r\n<span class=\"CodeIndent2\">width:80px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">height:80px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">margin:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;div&gt;\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n&lt;\/div&gt;<\/pre>\r\nContent before and after a floated element will attempt to wrap around it. When we do not want this to happen, we can add a rule to that element\u2019s style to clear the floating effect. To do this, we would add clear: left; clear: right; or clear:both depending which sides we are concerned with.\r\n<div class=\"textbox key-takeaways\">\r\n<h3 class=\"green-h\">Useful Feature<\/h3>\r\n<p class=\"green-p\">Since relative refers to moving the position from where it would be based on all of the other elements and rules, we can use negative values to \u201cpull\u201d an element in that particular direction.<\/p>\r\n\r\n<\/div>\r\n<h1>Positioning<\/h1>\r\nWe can specify, with great control, exactly where our elements are ultimately located in our window. CSS allows us to modify location to such an extent that an items position on the page can have no relation to its location in your code. Just as we have seen in many of our other rules, there are two methods to declaring position, fixed and relative. Here fixed elements specify the offset of pixels from a side or corner of the window, and relative declares that our values are moving the content from where it <em>would<\/em> have been if we had not changed it.\r\n\r\nHere is how we might take a heading and force it to an offset from the top left corner as an absolute, meaning it will sit there no matter what else is above, underneath, or around it:\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">h2 {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:absolute;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:50px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">top:100px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h2&gt;This is a heading with an absolute position&lt;\/h2&gt;\r\n\r\n&lt;p&gt;With absolute positioning, an element can be placed anywhere on a page. The heading below is placed 50px from the left of the page and 100px from the top of the page. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there.&lt;\/p&gt;<\/pre>\r\n<span class=\"Picture-4\"><img class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191401\/chap20_positioning_fmt.png\" alt=\"The positioning of a sentence behind a paragraph. Positioned via coding.\" width=\"593\" height=\"226\" \/><\/span>\r\n\r\nIf we wanted to move our heading relative to where it would normally have been positioned (just above our paragraph) we change to relative and provide the offset values that we want. Here, we will move it to the right, move it to the left, and show it as it was:\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">h2.pos_left {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:relative;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:-20px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">h2.pos_right {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:relative;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:20px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h2&gt;This is a heading with no position&lt;\/h2&gt;\r\n\r\n&lt;h2 class=\"pos_left\"&gt;This heading is moved left according to its normal position&lt;\/h2&gt;\r\n\r\n&lt;h2 class=\"pos_right\"&gt;This heading is moved right according to its normal position&lt;\/h2&gt;\r\n\r\n&lt;p&gt;This is our paragraph that has a heading with relative positioning. Unless we put a negative bottom offset on our heading large enough to cover it, it will stay above the paragraph this time. &lt;\/p&gt;<\/pre>\r\n<p class=\"No-Caption\"><em><span class=\"Picture-4\"><img class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191404\/chap20_positioning2_fmt.png\" alt=\"The positioning of different headings above a paragraph.\" width=\"758\" height=\"193\" \/><\/span><\/em><\/p>\r\n\r\n<h1>Z-index<\/h1>\r\nJust when you thought we had escaped the terrors of precedence and inheritance, we have another factor in our layering to consider. The z-index of an object determines its order in the stack of elements on a page. This is how we can control which items are depicted as on \u201ctop\u201d of another when they occupy the same portion of a page. While items are automatically layered according to their location on the page and in our code, these can be modified and overridden by a z-index to set the order we want. A larger value of a z-index forces an object \u201chigher\u201d on the page, or, puts it closer to the \u201ctop\u201d of all the elements you are looking at. A page background, for example, is usually the lowest level on your page. As such, other content on your page sits on top of your background layer, and becomes the next layer in the stack. A simple way to ensure important messages are never hidden behind something else is to assign them a z-index of an extremely large like 99999. You should only use such a method for one or two critical items in a site. In our first example, we will see an image with a negative index that ensures it is behind our text. Then we will change our index value to make it higher, putting it on top of the text instead:\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">img {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:absolute;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">top:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">z-index:-1;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h1&gt;Here is some text&lt;\/h1&gt;\r\n\r\n&lt;img src=\"http:\/\/bglabs.evade.netdna-cdn.com\/files\/clouds-seamless-background-824.jpg\" width=\"100\" height=\"100\" \/&gt;<\/pre>\r\n<img class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191406\/chap20_Zindex_fmt.png\" alt=\"A background behind the text.  Created via coding.\" width=\"243\" height=\"101\" \/>\r\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">img {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:absolute;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">top:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">z-index:-1;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h1&gt;Here is some text&lt;\/h1&gt;\r\n\r\n&lt;img src=\"http:\/\/bglabs.evade.netdna-cdn.com\/files\/clouds-seamless-background-824.jpg\" width=\"100\" height=\"100\" \/&gt;<\/pre>\r\n<img class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191407\/chap20_Zindex2_fmt.png\" alt=\"A background on top of some text, Created via coding.\" width=\"241\" height=\"103\" \/>\r\n<h1>Mouse Cursor<\/h1>\r\nWhile this is not a regular feature in most sites, it can be an important player if you intend for your website to act as if it were an application.\r\n\r\nWe can add cursor rules to our selectors in order to change the appearance of the mouse cursor when that rule is active. Much the same as working in your operating system, we can select the regular icon, wait (also called working, busy, thinking, etc.), text insert, a pointer, a question mark, and a crosshair. While most of these have little use in the average web page, they come in handy when your end product is more application focused.\r\n\r\nI would strongly recommend judicious use of cursor changes, and be sure that your changes are reverted back as soon as it is appropriate (i.e. change your waiting\/busy back as soon as an event is compete) as forgetting to reset can leave your user thinking your site (or their system) is locked up or endlessly cycling. The full list of the available cursors is as follows:\r\n<p class=\"Caption\"><em><a>Table 5 Pointer Styles<\/a><\/em><\/p>\r\n\r\n<table id=\"table-34\" class=\"Table-1\"><colgroup> <col \/> <col \/><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<th>\r\n<p class=\"Table-Heading\">Value<\/p>\r\n<\/th>\r\n<th>\r\n<p class=\"Table-Heading\">Description<\/p>\r\n<\/th>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">auto<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">(default) let the browser choose<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">crosshair<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Crosshair, or \u201cplus,\u201d symbol<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">default<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">The default cursor<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">e-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize to the right (note all resize values are compass combinations)<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">help<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">The help (question mark) icon<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">move<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Item can be moved<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">n-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize up<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">ne-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize up and right<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">nw-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize up and left<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">pointer<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">A pointer (arrow)<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">progress<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">The busy symbol (be careful with this one!)<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">s-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize down<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">se-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize down and right<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">sw-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize down and left<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">text<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Text line (flashing or steady \u201cI\u201d)<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>\r\n<p class=\"Table-Text\">w-resize<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows resize left<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr class=\"Row-Column-42\">\r\n<td>\r\n<p class=\"Table-Text\">wait<\/p>\r\n<\/td>\r\n<td>\r\n<p class=\"Table-Text\">Shows busy, wait (be careful with this one!)<\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td class=\"Footer-2\">\r\n<p class=\"Table-Text\">inherit<\/p>\r\n<\/td>\r\n<td class=\"Footer-2\">\r\n<p class=\"Table-Text\">Inherits value from parent<\/p>\r\n<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nCursor styles can be applied when the element with a CSS attribute that affects the cursor is triggered. This is usually caused by hovering over the object, or when the user initiates an action, in reaction to which we apply the new style using JavaScript. Note that user triggered actions like busy icons normally need to stay \u201cbusy\u201d until the script is done. In this case, the body tag should receive the attribute that affects the cursor so it continues to show as busy even if the user moves the mouse off of the button or other trigger that they used.\r\n<div class=\"textbox exercises\">\r\n<h3 class=\"learn-h\">Learn more<\/h3>\r\n<p class=\"learn-m\">Keywords, search terms: css layout, page formatting, positioning, css layers<\/p>\r\n<p class=\"learn-m\">LearnLayout: <a href=\"http:\/\/learnlayout.com\/toc.html\"><span class=\"Hyperlink\">http:\/\/learnlayout.com\/toc.html<\/span><\/a><\/p>\r\n<p class=\"learn-m\">Full layout example without tables: <a href=\"http:\/\/www.w3.org\/2002\/03\/csslayout-howto\"><span class=\"Hyperlink\">http:\/\/www.w3.org\/2002\/03\/csslayout-howto<\/span><\/a><\/p>\r\n<p class=\"learn-m\">A set of basic layouts: <a href=\"http:\/\/blog.html.it\/layoutgala\/\"><span class=\"Hyperlink\">http:\/\/blog.html.it\/layoutgala\/<\/span><\/a><\/p>\r\n\r\n<\/div>","rendered":"<h1 class=\"ChapterNumber\">\u00a0Box Model<\/h1>\n<div style=\"width: 552px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191348\/Boxmodell-detail_fmt.gif\" alt=\"A CSS Box Model\" width=\"542\" height=\"440\" \/><\/p>\n<p class=\"wp-caption-text\"><a href=\"http:\/\/commons.wikimedia.org\/wiki\/File:Boxmodell-detail.gif\">By Matthias Apsel [CC0]<\/a>, via Wikimedia Commons. Figure 24 CSS Box Model<\/p>\n<\/div>\n<h1>Borders<\/h1>\n<p class=\"BodyFirst\">To better identify where our content falls on a page, and to signify that it is different from the material around it, we can adjust the borders on our elements. Borders can be enabled or disabled by the top, bottom, left and right of the element and can also have different styles like solid, double, grooved, dotted and dashed lines, among others.<\/p>\n<p>To specify a full border, we simply use border, and can apply color, width, and style:<\/p>\n<table id=\"table-25\" class=\"blank\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<td>\n<pre>&lt;style&gt;\r\n\r\np.one {\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n}\r\n\r\np.two {\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n}\r\n\r\np.three {\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n}\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\n<\/td>\n<td><a href=\"https:\/\/milnepublishing.geneseo.edu\/themissinglink\/wp-content\/uploads\/sites\/4\/2015\/07\/Chap20_Margins1_fmt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-81 size-full\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191349\/Chap20_Margins1_fmt.png\" alt=\"Borders over text created via code.\" width=\"250\" height=\"128\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The full list of possible border styles is as follows:<\/p>\n<p class=\"Caption\"><em><a>Table 4 Border Styles<\/a><\/em><\/p>\n<table id=\"table-26\" class=\"Table-1\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<th>\n<p class=\"Table-Heading\">Value<\/p>\n<\/th>\n<th>\n<p class=\"Table-Heading\">Description<\/p>\n<\/th>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Small\">none<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">No border.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Small\">dotted<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Dotted border.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Small\">dashed<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Dashed border.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Small\">solid<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Solid border.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Small\">double<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Double (two lines) border.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Small\">groove<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Grooved, 3d border.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Small\">ridge<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Ridged, 3d border.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Small\">inset<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Lowered (sunken) 3d border.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Small\">outset<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Raised 3d border.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Small\">inherit<\/p>\n<\/td>\n<td>\n<p class=\"Table-Small\">Inherits the same style as the parent element.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>Margin and Padding<\/h1>\n<p>These related concepts allow you to control the amount of space between your content and its container, and between the container and objects around it. Padding controls the amount of space inside your container, for instance between text and a set of paragraph tags. You can remember padding as the inside by thinking about a padded room; the padding is only effective if it is on the inside of the walls.<\/p>\n<p>By adding borders to our paragraphs as we did above, we can see the outline of where the paragraph fits into our page. Now, we will see the difference when we apply padding:<\/p>\n<table id=\"table-27\" class=\"blank\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<td>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {padding:10px;}<\/strong><\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\n<\/td>\n<td><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191350\/chap20_margins_fmt.png\" alt=\"Padding added to borders around text via coding.\" width=\"262\" height=\"190\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You will notice that the paragraphs still have not moved relative to one another, they each simply take up more space. In order to move them further away from each other, we can add a margin:<\/p>\n<table id=\"table-28\" class=\"blank\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<td>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {padding:10px;}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {margin:50px;}<\/strong><\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\n<\/td>\n<td>\n<p class=\"Centered\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191351\/chap20_margins2_fmt.png\" alt=\"Margins added to border created via coding.\" width=\"278\" height=\"263\" \/><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>With both examples, we can adjust our values by pixel or percent. We can also control the amount of change by each side of the object, by specifying top, bottom, left or right to our rules. To do this we need to edit our values to only pad the left side of our paragraphs, and only apply a margin to the bottom of each:<\/p>\n<table id=\"table-29\" class=\"blank\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<td>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three{<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {padding-left:10px;}<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {margin-bottom:50px;}<\/strong><\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\n<\/td>\n<td><img decoding=\"async\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191353\/chap20_margins3_fmt.png\" alt=\"chap20_margins3.png\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Instead of writing out multiple rules to adjust sides, we can combine them into one declaration by writing out our values clockwise, starting with top, as padding: top right bottom left or margin: top right bottom left, replacing the words with a fixed or relative value (they can be mixed) and by using zero as a place holder if we do not want the value changed from default:<\/p>\n<table id=\"table-30\" class=\"blank\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<td>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\"><span class=\"Inline-Code\">}<\/span><\/span>\r\n\r\n<span class=\"CodeIndent1\"><span class=\"Inline-Code\">p.<\/span>two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\"><strong class=\"bold_code\">p {padding:50px 30px 50px 5px;}<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">p {margin:50px;}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\n<\/td>\n<td><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191354\/chap20_margins4_fmt.png\" alt=\"Text boxes with borders where the padding is being mixed around via coding\" width=\"270\" height=\"426\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1><a id=\"Background\"><\/a>Background<\/h1>\n<p>There is a lot we can do with the background of our pages. Colors and images can be applied to all or portions of our content, helping to highlight different elements of our site, and play a large part in the overall look and feel. We can specify colors by their name if they are a basic color like red, white, blue etc. or we can provide its hex value, or the values for its red, green, and blue values.<\/p>\n<table id=\"table-31\" class=\"blank\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<td>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">Background-color: green;<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">Background-color:#ff3355;<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background-color: rgb(33,66,99);<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {padding:50px 30px 50px 5px;}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {margin:50px;}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\n<\/td>\n<td><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191356\/chap20_background_fmt.png\" alt=\"Text boxes filled with color via coding\" width=\"272\" height=\"427\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>To use images instead of colors, we can specify the image\u2019s location in our files, and can also dictate where we want to place it on our page, whether or not it should repeat, and whether it should move or remain in place when the user scrolls the page. By default, images will repeat to fill the space they are placed in. To prevent this, we can add a no-repeat attribute to our definitions. This time, we will use the background attribute as opposed to the background-color attribute. The benefit of this is that you can include both in a set of rules on the same object (image first, color second), allowing you to have an image on top of a background color. Take note that in these examples, you will need to select your own images in place of those used below.<\/p>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">p.one {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:solid;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:5px;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background:url(clouds.jpg);<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent2\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.two {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:groove;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:medium;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background:url(calendar.jpg) no-repeat;<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent2\">background-color:#ff3355;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p.three {<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-style:dotted;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-width:1px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">border-color:red;<\/span>\r\n\r\n<span class=\"CodeIndent2\"><strong class=\"bold_code\">background:url(calendar.jpg);<\/strong><\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {padding:50px 30px 50px 5px;}<\/span>\r\n\r\n<span class=\"CodeIndent1\">p {margin:50px;}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;p class=\"one\"&gt;Some text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"two\"&gt;Some more text.&lt;\/p&gt;\r\n\r\n&lt;p class=\"three\"&gt;Even more text.&lt;\/p&gt;<\/pre>\n<p class=\"BodyFirst\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191358\/chap20_background2_fmt.png\" alt=\"Textboxes with backgrounds inserted via coding\" width=\"279\" height=\"434\" \/><\/p>\n<p>There are two ways of achieving this affect. The first is by using advanced styling through CSS using <span class=\"Hyperlink\">WebKit<\/span> features supported by some browsers, and then adding style rules to create the effect as close as possible in other browsers. The second is by creating a repeatable gradient image. The first approach\u2019s reliance on WebKit provides support for Apple and Google products. For browsers that do not use WebKit, we have to add extra rules to achieve the same effect. This is a more advanced example as it requires knowledge of each browser\u2019s needs to create:<\/p>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">#ourBackground {<\/span>\r\n\r\n<span class=\"CodeIndent2\">background-color: #1a82f7;<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: url(ourFallBackImage.png);<\/span>\r\n\r\n<span class=\"CodeIndent2\">background-repeat: repeat-x;<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Safari 4-5, Chrome 1-9 *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727));<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Safari 5.1, Chrome 10+ *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -webkit-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Firefox 3.6+ *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -moz-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* IE 10 *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -ms-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent2\">\/* Opera 11.10+ *\/<\/span>\r\n\r\n<span class=\"CodeIndent2\">background: -o-linear-gradient(top, #2F2727, #1a82f7);<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;div id=\"ourBackground\" width=\"300px\" height=\"300px\"&gt;\r\n\r\n<span class=\"CodeIndent1\">&lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">Some &lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">Text &lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">Here &lt;br\/&gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;br\/&gt;<\/span>\r\n\r\n&lt;\/div&gt;<\/pre>\n<p>This code should produce an almost identical image in every browser, depending on which rule(s) the browser is able to execute:<\/p>\n<p><span class=\"Picture-4\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191359\/chap20_background3_fmt.png\" alt=\"A text box with a blue background created via code.\" width=\"274\" height=\"113\" \/><\/span><\/p>\n<p>The first three lines of this style script\u2014<\/p>\n<pre>background-color: #1a82f7;\r\n\r\nbackground: url(ourFallBackImage.png);\r\n\r\nbackground-repeat: repeat-x;<\/pre>\n<p>demonstrate how we create the gradient effect through an image. In this example, ourFallBackImage.png would be a very skinny (1 pixel) wide image as tall as we want our gradient to be. By repeating this image across the X axis (moving horizontally) the image will fill the width of the parent object. By specifying the bottom-most pixel color from our image as the background, the gradient will appear to fill the page. The balance of our rules in this example achieve the same result through CSS, but also provides more control over the gradient without needing to create additional images.<\/p>\n<h1>Float<\/h1>\n<p>Floating an object with CSS allows us to move it around within its parent object, ignoring (to some extent) the other items near it. Note that float is only for left\/right values, not top\/bottom, even though their movement may feel that way as windows resize.<\/p>\n<p>When multiple objects in the same container have the same float style, they will line up next to each other for as many as the container can fit. While this may sound confusing, we will look at it without the terminology: If you have a big box, and that box has small boxes in it, those boxes will fit as many of themselves left-to-right in a row as they can. Any boxes that do not fit will start a new \u201crow\u201d underneath.<\/p>\n<p>The use of float is a big help to responsive styling. Boxes of content that normally fit side by side on a larger screen will automatically create more \u201crows,\u201d with less items in each, to accommodate screens with less width. Create a page with the following code, and then play around with the size of your browser window to see the resizing in action:<\/p>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">.thumbnail {<\/span>\r\n\r\n<span class=\"CodeIndent2\">float:left;<\/span>\r\n\r\n<span class=\"CodeIndent2\">width:80px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">height:80px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">margin:5px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;div&gt;\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n<span class=\"CodeIndent1\">&lt;img class=\"thumbnail\" src=\"yourPictureHere.jpg\" &gt;<\/span>\r\n\r\n&lt;\/div&gt;<\/pre>\n<p>Content before and after a floated element will attempt to wrap around it. When we do not want this to happen, we can add a rule to that element\u2019s style to clear the floating effect. To do this, we would add clear: left; clear: right; or clear:both depending which sides we are concerned with.<\/p>\n<div class=\"textbox key-takeaways\">\n<h3 class=\"green-h\">Useful Feature<\/h3>\n<p class=\"green-p\">Since relative refers to moving the position from where it would be based on all of the other elements and rules, we can use negative values to \u201cpull\u201d an element in that particular direction.<\/p>\n<\/div>\n<h1>Positioning<\/h1>\n<p>We can specify, with great control, exactly where our elements are ultimately located in our window. CSS allows us to modify location to such an extent that an items position on the page can have no relation to its location in your code. Just as we have seen in many of our other rules, there are two methods to declaring position, fixed and relative. Here fixed elements specify the offset of pixels from a side or corner of the window, and relative declares that our values are moving the content from where it <em>would<\/em> have been if we had not changed it.<\/p>\n<p>Here is how we might take a heading and force it to an offset from the top left corner as an absolute, meaning it will sit there no matter what else is above, underneath, or around it:<\/p>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">h2 {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:absolute;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:50px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">top:100px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h2&gt;This is a heading with an absolute position&lt;\/h2&gt;\r\n\r\n&lt;p&gt;With absolute positioning, an element can be placed anywhere on a page. The heading below is placed 50px from the left of the page and 100px from the top of the page. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there. As this text continues, you will see that the heading sits on top of the text as if it was not even there.&lt;\/p&gt;<\/pre>\n<p><span class=\"Picture-4\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191401\/chap20_positioning_fmt.png\" alt=\"The positioning of a sentence behind a paragraph. Positioned via coding.\" width=\"593\" height=\"226\" \/><\/span><\/p>\n<p>If we wanted to move our heading relative to where it would normally have been positioned (just above our paragraph) we change to relative and provide the offset values that we want. Here, we will move it to the right, move it to the left, and show it as it was:<\/p>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">h2.pos_left {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:relative;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:-20px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n<span class=\"CodeIndent1\">h2.pos_right {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:relative;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:20px;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h2&gt;This is a heading with no position&lt;\/h2&gt;\r\n\r\n&lt;h2 class=\"pos_left\"&gt;This heading is moved left according to its normal position&lt;\/h2&gt;\r\n\r\n&lt;h2 class=\"pos_right\"&gt;This heading is moved right according to its normal position&lt;\/h2&gt;\r\n\r\n&lt;p&gt;This is our paragraph that has a heading with relative positioning. Unless we put a negative bottom offset on our heading large enough to cover it, it will stay above the paragraph this time. &lt;\/p&gt;<\/pre>\n<p class=\"No-Caption\"><em><span class=\"Picture-4\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191404\/chap20_positioning2_fmt.png\" alt=\"The positioning of different headings above a paragraph.\" width=\"758\" height=\"193\" \/><\/span><\/em><\/p>\n<h1>Z-index<\/h1>\n<p>Just when you thought we had escaped the terrors of precedence and inheritance, we have another factor in our layering to consider. The z-index of an object determines its order in the stack of elements on a page. This is how we can control which items are depicted as on \u201ctop\u201d of another when they occupy the same portion of a page. While items are automatically layered according to their location on the page and in our code, these can be modified and overridden by a z-index to set the order we want. A larger value of a z-index forces an object \u201chigher\u201d on the page, or, puts it closer to the \u201ctop\u201d of all the elements you are looking at. A page background, for example, is usually the lowest level on your page. As such, other content on your page sits on top of your background layer, and becomes the next layer in the stack. A simple way to ensure important messages are never hidden behind something else is to assign them a z-index of an extremely large like 99999. You should only use such a method for one or two critical items in a site. In our first example, we will see an image with a negative index that ensures it is behind our text. Then we will change our index value to make it higher, putting it on top of the text instead:<\/p>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">img {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:absolute;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">top:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">z-index:-1;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h1&gt;Here is some text&lt;\/h1&gt;\r\n\r\n&lt;img src=\"http:\/\/bglabs.evade.netdna-cdn.com\/files\/clouds-seamless-background-824.jpg\" width=\"100\" height=\"100\" \/&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191406\/chap20_Zindex_fmt.png\" alt=\"A background behind the text.  Created via coding.\" width=\"243\" height=\"101\" \/><\/p>\n<pre>&lt;style&gt;\r\n\r\n<span class=\"CodeIndent1\">img {<\/span>\r\n\r\n<span class=\"CodeIndent2\">position:absolute;<\/span>\r\n\r\n<span class=\"CodeIndent2\">left:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">top:0px;<\/span>\r\n\r\n<span class=\"CodeIndent2\">z-index:-1;<\/span>\r\n\r\n<span class=\"CodeIndent1\">}<\/span>\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;h1&gt;Here is some text&lt;\/h1&gt;\r\n\r\n&lt;img src=\"http:\/\/bglabs.evade.netdna-cdn.com\/files\/clouds-seamless-background-824.jpg\" width=\"100\" height=\"100\" \/&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/1755\/2017\/04\/21191407\/chap20_Zindex2_fmt.png\" alt=\"A background on top of some text, Created via coding.\" width=\"241\" height=\"103\" \/><\/p>\n<h1>Mouse Cursor<\/h1>\n<p>While this is not a regular feature in most sites, it can be an important player if you intend for your website to act as if it were an application.<\/p>\n<p>We can add cursor rules to our selectors in order to change the appearance of the mouse cursor when that rule is active. Much the same as working in your operating system, we can select the regular icon, wait (also called working, busy, thinking, etc.), text insert, a pointer, a question mark, and a crosshair. While most of these have little use in the average web page, they come in handy when your end product is more application focused.<\/p>\n<p>I would strongly recommend judicious use of cursor changes, and be sure that your changes are reverted back as soon as it is appropriate (i.e. change your waiting\/busy back as soon as an event is compete) as forgetting to reset can leave your user thinking your site (or their system) is locked up or endlessly cycling. The full list of the available cursors is as follows:<\/p>\n<p class=\"Caption\"><em><a>Table 5 Pointer Styles<\/a><\/em><\/p>\n<table id=\"table-34\" class=\"Table-1\">\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<th>\n<p class=\"Table-Heading\">Value<\/p>\n<\/th>\n<th>\n<p class=\"Table-Heading\">Description<\/p>\n<\/th>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">auto<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">(default) let the browser choose<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">crosshair<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Crosshair, or \u201cplus,\u201d symbol<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">default<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">The default cursor<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">e-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize to the right (note all resize values are compass combinations)<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">help<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">The help (question mark) icon<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">move<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Item can be moved<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">n-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize up<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">ne-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize up and right<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">nw-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize up and left<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">pointer<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">A pointer (arrow)<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">progress<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">The busy symbol (be careful with this one!)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">s-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize down<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">se-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize down and right<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">sw-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize down and left<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">text<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Text line (flashing or steady \u201cI\u201d)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p class=\"Table-Text\">w-resize<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows resize left<\/p>\n<\/td>\n<\/tr>\n<tr class=\"Row-Column-42\">\n<td>\n<p class=\"Table-Text\">wait<\/p>\n<\/td>\n<td>\n<p class=\"Table-Text\">Shows busy, wait (be careful with this one!)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"Footer-2\">\n<p class=\"Table-Text\">inherit<\/p>\n<\/td>\n<td class=\"Footer-2\">\n<p class=\"Table-Text\">Inherits value from parent<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Cursor styles can be applied when the element with a CSS attribute that affects the cursor is triggered. This is usually caused by hovering over the object, or when the user initiates an action, in reaction to which we apply the new style using JavaScript. Note that user triggered actions like busy icons normally need to stay \u201cbusy\u201d until the script is done. In this case, the body tag should receive the attribute that affects the cursor so it continues to show as busy even if the user moves the mouse off of the button or other trigger that they used.<\/p>\n<div class=\"textbox exercises\">\n<h3 class=\"learn-h\">Learn more<\/h3>\n<p class=\"learn-m\">Keywords, search terms: css layout, page formatting, positioning, css layers<\/p>\n<p class=\"learn-m\">LearnLayout: <a href=\"http:\/\/learnlayout.com\/toc.html\"><span class=\"Hyperlink\">http:\/\/learnlayout.com\/toc.html<\/span><\/a><\/p>\n<p class=\"learn-m\">Full layout example without tables: <a href=\"http:\/\/www.w3.org\/2002\/03\/csslayout-howto\"><span class=\"Hyperlink\">http:\/\/www.w3.org\/2002\/03\/csslayout-howto<\/span><\/a><\/p>\n<p class=\"learn-m\">A set of basic layouts: <a href=\"http:\/\/blog.html.it\/layoutgala\/\"><span class=\"Hyperlink\">http:\/\/blog.html.it\/layoutgala\/<\/span><\/a><\/p>\n<\/div>\n\n\t\t\t <section class=\"citations-section\" role=\"contentinfo\">\n\t\t\t <h3>Candela Citations<\/h3>\n\t\t\t\t\t <div>\n\t\t\t\t\t\t <div id=\"citation-list-110\">\n\t\t\t\t\t\t\t <div class=\"licensing\"><div class=\"license-attribution-dropdown-subheading\">CC licensed content, Shared previously<\/div><ul class=\"citation-list\"><li>The Missing Link. <strong>Authored by<\/strong>: Michael Mendez. <strong>Provided by<\/strong>: Open SUNY Textbooks. <strong>Located at<\/strong>: <a target=\"_blank\" href=\"https:\/\/textbooks.opensuny.org\/the-missing-link-an-introduction-to-web-development-and-programming\/\">https:\/\/textbooks.opensuny.org\/the-missing-link-an-introduction-to-web-development-and-programming\/<\/a>. <strong>License<\/strong>: <em><a target=\"_blank\" rel=\"license\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/4.0\/\">CC BY-NC-SA: Attribution-NonCommercial-ShareAlike<\/a><\/em><\/li><\/ul><\/div>\n\t\t\t\t\t\t <\/div>\n\t\t\t\t\t <\/div>\n\t\t\t <\/section>","protected":false},"author":311,"menu_order":15,"template":"","meta":{"_candela_citation":"[{\"type\":\"cc\",\"description\":\"The Missing Link\",\"author\":\"Michael Mendez\",\"organization\":\"Open SUNY Textbooks\",\"url\":\"https:\/\/textbooks.opensuny.org\/the-missing-link-an-introduction-to-web-development-and-programming\/\",\"project\":\"\",\"license\":\"cc-by-nc-sa\",\"license_terms\":\"\"}]","CANDELA_OUTCOMES_GUID":"","pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-110","chapter","type-chapter","status-publish","hentry"],"part":62,"_links":{"self":[{"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/pressbooks\/v2\/chapters\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/wp\/v2\/users\/311"}],"version-history":[{"count":6,"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/pressbooks\/v2\/chapters\/110\/revisions"}],"predecessor-version":[{"id":336,"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/pressbooks\/v2\/chapters\/110\/revisions\/336"}],"part":[{"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/pressbooks\/v2\/parts\/62"}],"metadata":[{"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/pressbooks\/v2\/chapters\/110\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/pressbooks\/v2\/chapter-type?post=110"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/wp\/v2\/contributor?post=110"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-the-missing-link-an-introduction-to-web-development-and-programming\/wp-json\/wp\/v2\/license?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}