{"id":38,"date":"2020-08-01T14:25:04","date_gmt":"2020-08-01T18:25:04","guid":{"rendered":"https:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/chapter\/tutorial-3-%e2%80%a2-styles\/"},"modified":"2021-07-23T15:29:18","modified_gmt":"2021-07-23T19:29:18","slug":"tutorial-3-styles","status":"publish","type":"chapter","link":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/chapter\/tutorial-3-styles\/","title":{"raw":"Tutorial 3 \u2022 Styles, Fonts, and Tables","rendered":"Tutorial 3 \u2022 Styles, Fonts, and Tables"},"content":{"raw":"<div class=\"tutorial-3-\u2022-styles\">\r\n<h1>CSS Styles<\/h1>\r\nIt's commonly said that HTML gives structure to your page, while cascading style sheets (CSS) determines its appearance. CSS has two meanings: (1) a file of type .css, and (2) the hierarchy of styles, i.e., that a local\/inline style overrides a global\/embedded style, which in turn overrides an external .css file.\r\n\r\nThree ways of writing styles:\r\n<p style=\"padding-left: 40px\"><strong>Local or inline style.<\/strong> A style=\"\" statement inside a tag, e.g., &lt;p style=\"font-family: Roboto;\"&gt;. Local\/inline styles override global\/embedded and CSS files.<\/p>\r\n<p style=\"padding-left: 40px\"><strong>Global or embedded style.<\/strong> A &lt;style&gt; tag with statements in the document head. Global\/embedded styles override CSS files.<\/p>\r\n<p style=\"padding-left: 40px\"><strong>CSS file.<\/strong> A separate file of type .css that can be applied to multiple pages, e.g. file \"styles.css\" attached to a page, &lt;link href=\"styles.css\" type=\"text\/css\" rel=\"stylesheet\"&gt;<\/p>\r\n\r\n<div style=\"width: 100%;background: azure;margin: 12px auto;border: 1px dotted lightblue;padding: 12px\">\r\n<h2>Making a CSS File<\/h2>\r\n<ol>\r\n \t<li>Copy the global\/embedded styles from one of your pages into a separate file, without the &lt;style&gt; tags, and save with file extension .css, e.g., \"styles.css.\"<\/li>\r\n \t<li>Link your .css file to both pages using the &lt;link&gt; tag:\r\n<pre>&lt;link href=\"styles.css\" type=\"text\/css\" rel=\"stylesheet\"&gt;<\/pre>\r\n<\/li>\r\n \t<li>Verify that the styles take effect and that the .css file appears as a separate Dreamweaver tab in your document.<\/li>\r\n<\/ol>\r\n<\/div>\r\n<h2>Using Selectors<\/h2>\r\nSelectors are like the strings on a marionette\u2014they connect the tags with the styles you want to apply. You can select all tags by writing the tag in a style statement and the styles in braces, e.g., p {font-family: Georgia;} selects all paragraphs and sets them in the font Georgia. But what if you want to style different paragraphs differently? In that case you can label the paragraph with an ID (use once on a page) or with a class (used multiple times).\u00a0Select the ID in CSS using a hash tag # and a class by preceding it with a dot.\r\n\r\nPseudoclasses are a type of class that\u2019s built in to the HTML5 and does not need to be labeled by the designer. Example: p:nth-child(1) selects the first paragraph.\r\n\r\n<\/div>\r\nAnother way to select tags for styling is to use the structure of the HTML. Example: you used an unordered list of bullet points to make a navigation menu, and you placed the list within a navigation or &lt;nav&gt; tag. You can select only that list by writing \u201cnav ul.\u201d Other lists on the page will not be affected.\r\n<div class=\"tutorial-3-\u2022-styles\">\r\n\r\nA great exercise on selectors is the \u201cCSS Diner\u201d at <a href=\"http:\/\/flukeout.github.io\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/flukeout.github.io<\/a>. To select one or more items out of several:\r\n<table>\r\n<tbody>\r\n<tr style=\"background: whitesmoke\">\r\n<th colspan=\"3\">Methods of Selecting Tags for Styling<\/th>\r\n<\/tr>\r\n<tr>\r\n<td width=\"60%\"><strong><em>Selection method<\/em><\/strong><\/td>\r\n<td width=\"20%\"><strong><em>Example in HTML<\/em><\/strong><\/td>\r\n<td width=\"20%\"><strong><em>Example in CSS<\/em><\/strong><\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>Use an ID (for one item)<\/td>\r\n<td>&lt;p id=\"para1\"&gt;<\/td>\r\n<td>#para1 {}<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Use a class (for multiple items)<\/td>\r\n<td>&lt;p class=\"para1\"&gt;<\/td>\r\n<td>.para1 {}<\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>Use a pseudoselector (for first, second, or a repeating pattern of connected items, known as \u201cchildren\u201d)<\/td>\r\n<td>\u2014\r\n(built into HTML5)<\/td>\r\n<td>p:nth-child(1)\r\n1, 2, 3, \u2026,\r\nodd, even\r\n1n+3 (every 3 starting with 1st)<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Use the HTML structure, e.g., &lt;div&gt; with an &lt;img&gt; tag in it<\/td>\r\n<td>&lt;div&gt;&lt;img&gt;<\/td>\r\n<td>div img {}<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<h2>What to Style<\/h2>\r\nTwo demo files from Patrick Carey\u2019s textbook, <em>New Perspectives on HTML<\/em> (Thompson) show examples of how you can style text and color. (A third shows the web-safe palette.)\r\n<p class=\"import-ListBullet\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image1-1.png\" width=\"768\" height=\"1066\" alt=\"This page demonstrates how different styles affect the appearance of Web page text. Enter your sample text in the box in the upper-right corner of this page. When you press the Tab key, the text will be copied to the Preview box. Set the styles for the preview text by entering or selecting the style value from the input boxes on the left and then pressing the Tab key. To apply the default style values, enter or select &quot;default&quot;. The style selections will be applied automatically to the preview text and the style code will be displayed in the box on the lower-right of the page. To reset all of the styles to their default values, click the Reset Styles button at the bottom of the page.\" class=\"aligncenter\" \/><\/p>\r\n<strong>demo_text_styles<\/strong><strong>.<\/strong> Notice all the characteristics of type that you can style. Some common ones include:\r\n<ul>\r\n \t<li>font-family\u2014the typeface<\/li>\r\n \t<li>font-weight\u2014bold<\/li>\r\n \t<li>font-style\u2014italic<\/li>\r\n<\/ul>\r\n<a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1.png\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-1024x170.png\" alt=\"You define colors in HTML and XHTML using either a color name or a color value. HTML and XHTML support a list of 16 basic color names. Most browsers also support an extended set of color names. The following table lists these extended color names, along with RGB and hexadecimal values for each color. The sixteen color names supported by HTML and XHTML are highlighted in the table. Web-safe colors are displayed in a bold font.\" width=\"1024\" height=\"170\" class=\"aligncenter wp-image-33 size-large\" \/><\/a>\r\n\r\n<strong>demo_color_names<\/strong><strong>.<\/strong>\u00a0A palette of the 140 named colors and four ways to specify them:\r\n<ul>\r\n \t<li>named colors\u2014red, green, blue, lightblue, azure, chartreuse, \u2026 102 names<\/li>\r\n \t<li>rgb\u2014red, green, and blue values, scale 0\u2013255, e.g., color: rgb(255,0,0);<\/li>\r\n \t<li>rgba\u2014\u201ca\u201d adds the \u201calpha channel,\u201d or transparency, from 0-1.00, where 0 is completely invisible and 1.00 is opaque.<\/li>\r\n \t<li>hex\u20143 or 6 numbers and letters on a scale of 0-16, where 10=A, 11=B, etc. Difficult to comprehend if you are trying to figure out what color it is.<\/li>\r\n<\/ul>\r\n<h4>What to color<\/h4>\r\n<ul>\r\n \t<li>color: red; \u2014will color text<\/li>\r\n \t<li>background: red; \u2014colors objects, like \u201cfill\u201d in Illustrator or Photoshop<\/li>\r\n<\/ul>\r\n<h4>Space<\/h4>\r\n<ul>\r\n \t<li>margin: all around; margin: top bottom; margin: top right bottom left\u2014determines space around an object; margin: 0 auto will center an object if its width is specified and it's a block-level element.<\/li>\r\n \t<li>padding: expands an object (including background color)<\/li>\r\n<\/ul>\r\n[caption id=\"attachment_187\" align=\"aligncenter\" width=\"768\"]<a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins.jpg\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins.jpg\" alt=\"\" width=\"768\" height=\"442\" class=\"wp-image-187\" \/><\/a> Demonstration showing the difference between margin, padding, border, and table cell spacing.[\/caption]\r\n<h4>Size<\/h4>\r\n<ul>\r\n \t<li>width<\/li>\r\n \t<li>height<\/li>\r\n<\/ul>\r\n<p class=\"import-Normal\" style=\"text-align: center\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image3.jpg\" width=\"512px\" height=\"auto\" alt=\"image\" \/><\/p>\r\n\r\n<h2>Working with Fonts<\/h2>\r\nTwo ways to include an unusual or decorative font on a web page are to place the font on the server and access it using the @font-face rule, and use a Google or other free font.\r\n<h3>Including a Font on Your Server<\/h3>\r\nIf you want to use an unusual font and you are unsure if users will have this font on their computers, you can put the font file on your server and link to it using the \u201c@font-face\u201d rule. In this example, the font candara.ttf was placed on the server in the same folder as the styles.css file and linked similar to a background image.\r\n<p class=\"import-Normal\" style=\"text-align: center\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image4.jpg\" width=\"350\" height=\"160\" alt=\"CSS code example: @font-face { font-family: Candara; src: url(candara.tff);\" class=\"alignnone\" \/><\/p>\r\n\r\n<div style=\"width: 100%;background: azure;margin: 12px auto;border: 1px dotted lightblue;padding: 12px\">\r\n<h3>Using a Google Font<\/h3>\r\nGoogle has numerous free fonts available on its web site, <a class=\"rId11\" href=\"http:\/\/www.google.com\/fonts\">Google Fonts <em>[New Window]<\/em><\/a>. The font information can be linked to your web page using the &lt;link&gt; rule. To use a Google font:\r\n<ol>\r\n \t<li class=\"import-Normal\">Browse the available fonts and add one you want to your collection.<\/li>\r\n \t<li class=\"import-Normal\">Access your font collection to get the link to the font and the syntax to cite the font.<\/li>\r\n \t<li class=\"import-Normal\">In this example, the font \u201cNova Flat\u201d was accessed:<\/li>\r\n<\/ol>\r\n<p style=\"padding-left: 40px\">Embed code:<\/p>\r\n\r\n<pre style=\"padding-left: 40px\">&lt;link href=\u201dhttps:\/\/fonts.googleapis.com\/css?family=Nova+Flat\u201d rel=\u201dstylesheet\u201d&gt;<\/pre>\r\n<ol start=\"4\">\r\n \t<li>To use the font:<\/li>\r\n<\/ol>\r\n<pre class=\"import-Normal\" style=\"padding-left: 40px\">font-family: \u2018Nova Flat\u2019, cursive;<\/pre>\r\n<\/div>\r\n&nbsp;\r\n<table style=\"margin: 0 auto;width: 80%\">\r\n<tbody>\r\n<tr>\r\n<td><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image5.jpg\" width=\"312\" height=\"682\" alt=\"Example of the font face Nova Flat visualization on Google Fonts\" class=\"alignnone\" \/><\/td>\r\n<td><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image6.jpg\" width=\"424\" height=\"1196\" alt=\"Example of embed option for font faces on Google Fonts\" class=\"alignnone\" \/><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<h2>Tables<\/h2>\r\nTables are a nice way to organize information that's easy for readers to comprehend. Basic table tags are table &lt;table&gt;, table rows &lt;tr&gt;, and table data &lt;td&gt; which refers to the cells and therefore the columns. (There is no tag for table columns, they are determined by the cells.)\r\n\r\nVarious styles can be applied to the table, tr, and td tags including the border, color (of font), and background, including an image background. \u201cPseudoselectors\u201d including nth-child(odd) can be used to shade alternating rows to differentiate them more imaginatively than with the traditional borders.\r\n<h3 class=\"import-ListBullet\">Anatomy of a Table<\/h3>\r\n<table style=\"margin: 0 auto;background: whitesmoke;width: 67%\">\r\n<tbody>\r\n<tr>\r\n<td><strong>&lt;table&gt;<\/strong><\/td>\r\n<td>\r\n<p style=\"text-align: center\"><strong>&lt;td&gt;<\/strong><\/p>\r\n<\/td>\r\n<td>\r\n<p style=\"text-align: center\"><strong>&lt;td&gt;<\/strong><\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>&lt;tr&gt;<\/strong><\/td>\r\n<td>Row 1, Column 1<\/td>\r\n<td>Row 1, Column 2<\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>&lt;tr&gt;<\/strong><\/td>\r\n<td>Row 2, Column 1<\/td>\r\n<td>Row 2, Column 2<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<p class=\"import-ListBullet\" style=\"margin-left: 72px;margin-right: 72px\"><em>Sample table (above) and the tags for the table &lt;table&gt;, rows &lt;tr&gt;, and columns (cells, &lt;td&gt;). Columns are determined by the cells. Code below.<\/em><\/p>\r\n&nbsp;\r\n<div class=\"textbox shaded\" style=\"background: whitesmoke;width: 67%;margin: 0 auto\">\r\n\r\n&lt;table&gt;\r\n<p style=\"padding-left: 40px\">&lt;tr&gt;<\/p>\r\n<p style=\"padding-left: 80px\">&lt;td&gt;Row 1, Column 1&lt;\/td&gt;&lt;td&gt;Row 1, Column 2&lt;\/td&gt;<\/p>\r\n<p style=\"padding-left: 40px\">&lt;\/tr&gt;<\/p>\r\n<p style=\"padding-left: 40px\">&lt;tr&gt;<\/p>\r\n<p style=\"padding-left: 80px\">&lt;td&gt;Row 2, Column 1&lt;\/td&gt;&lt;td&gt;Row 2, Column 2&lt;\/td&gt;<\/p>\r\n<p style=\"padding-left: 40px\">&lt;\/tr&gt;<\/p>\r\n&lt;\/table&gt;\r\n\r\n<\/div>\r\n&nbsp;\r\n<table style=\"margin: 0 auto;width: 80%\">\r\n<tbody>\r\n<tr style=\"background: whitesmoke\">\r\n<th colspan=\"2\">Table Tags<\/th>\r\n<\/tr>\r\n<tr>\r\n<th>Tag<\/th>\r\n<th>Description<\/th>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>&lt;table&gt;&lt;\/table&gt;<\/td>\r\n<td>table<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&lt;tr&gt;&lt;\/tr&gt;<\/td>\r\n<td>table row\r\nmerge\u2014number of columns to span<\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>&lt;td&gt;&lt;\/td&gt;<\/td>\r\n<td>table data\u2014columns\r\n\u2022 there is no \"column\" tag because the columns are determined by the cells<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&lt;th&gt;&lt;\/th&gt;<\/td>\r\n<td>table header\r\n\u2022 first row(s), type will be bold centered<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n&nbsp;\r\n<table style=\"margin: 0 auto;width: 80%\">\r\n<tbody>\r\n<tr style=\"background: whitesmoke\">\r\n<th colspan=\"2\">CSS Styles Useful to Table Tags<\/th>\r\n<\/tr>\r\n<tr>\r\n<td><strong>Style<\/strong><\/td>\r\n<td><strong>Description<\/strong><\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>border<\/td>\r\n<td>px color, e.g., border: 1px solid gray;<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>padding<\/td>\r\n<td>text inset, e.g., padding: 12px;<\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>spacing<\/td>\r\n<td>space between cells<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>background: color;\r\nbackground-image: url(image.jpg);<\/td>\r\n<td>color of table, rows, and\/or cells; could include background image;\r\n\u2022 color: rgb(0,0,0);\r\n\u2022 color: #fff;\r\n\u2022 background: (url \"image.jpg\");<\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>pseudo-selectors\r\n:nth-child(1)\r\n:nth-child(odd)\r\n:nth-child(even)\r\n:first-child\r\n:last-child\r\n:nth-child(3n)<\/td>\r\n<td>first item in a group of multiple\r\nall odd-numbered items\r\nall even-numbered items\r\nfirst item\r\nlast item\r\nevery 3rd item<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<div style=\"width: 100%;background: azure;margin: 12px auto;border: 1px dotted lightblue;padding: 12px\">\r\n<h3>Importing Table Text<\/h3>\r\n<ol>\r\n \t<li>Import the table text (table.txt) into Dreamweaver: File &gt; Import &gt; Tabular Data.<\/li>\r\n \t<li>Style the table by:<\/li>\r\n<\/ol>\r\n<ul>\r\n \t<li style=\"list-style-type: none\">\r\n<ul>\r\n \t<li>inserting an embedded or global &lt;style&gt; tag in the &lt;head&gt;<\/li>\r\n \t<li>selecting the table elements (&lt;table&gt;, etc., see Table 1 below)<\/li>\r\n \t<li>applying the specifications you want (Table 2 below)<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n&nbsp;\r\n<table style=\"margin: 0 auto;width: 90%\">\r\n<tbody>\r\n<tr style=\"background: lightblue\">\r\n<th colspan=\"3\">Russian Fairytale Boxes<\/th>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<th>Box<\/th>\r\n<th>Characters<\/th>\r\n<th>English Counterpart<\/th>\r\n<\/tr>\r\n<tr style=\"background: azure\">\r\n<td>The Grey Wolf<\/td>\r\n<td>Ivan Tsarevitch, Helen the Beautiful, the Grey Wolf<\/td>\r\n<td>none<\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>The Horse with the Golden Mane<\/td>\r\n<td>Ivan Tsarevitch and the Horse with the Golden Mane<\/td>\r\n<td>The Magic Pony<\/td>\r\n<\/tr>\r\n<tr style=\"background: azure\">\r\n<td>The Firebird<\/td>\r\n<td>Ivan Tsarevitch and the Firebird<\/td>\r\n<td>The Phoenix<\/td>\r\n<\/tr>\r\n<tr style=\"background: whitesmoke\">\r\n<td>Father Frost<\/td>\r\n<td>Father Frost, the Snow Queen, and a troika of horses<\/td>\r\n<td>Santa Clause<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>","rendered":"<div class=\"tutorial-3-\u2022-styles\">\n<h1>CSS Styles<\/h1>\n<p>It&#8217;s commonly said that HTML gives structure to your page, while cascading style sheets (CSS) determines its appearance. CSS has two meanings: (1) a file of type .css, and (2) the hierarchy of styles, i.e., that a local\/inline style overrides a global\/embedded style, which in turn overrides an external .css file.<\/p>\n<p>Three ways of writing styles:<\/p>\n<p style=\"padding-left: 40px\"><strong>Local or inline style.<\/strong> A style=&#8221;&#8221; statement inside a tag, e.g., &lt;p style=&#8221;font-family: Roboto;&#8221;&gt;. Local\/inline styles override global\/embedded and CSS files.<\/p>\n<p style=\"padding-left: 40px\"><strong>Global or embedded style.<\/strong> A &lt;style&gt; tag with statements in the document head. Global\/embedded styles override CSS files.<\/p>\n<p style=\"padding-left: 40px\"><strong>CSS file.<\/strong> A separate file of type .css that can be applied to multiple pages, e.g. file &#8220;styles.css&#8221; attached to a page, &lt;link href=&#8221;styles.css&#8221; type=&#8221;text\/css&#8221; rel=&#8221;stylesheet&#8221;&gt;<\/p>\n<div style=\"width: 100%;background: azure;margin: 12px auto;border: 1px dotted lightblue;padding: 12px\">\n<h2>Making a CSS File<\/h2>\n<ol>\n<li>Copy the global\/embedded styles from one of your pages into a separate file, without the &lt;style&gt; tags, and save with file extension .css, e.g., &#8220;styles.css.&#8221;<\/li>\n<li>Link your .css file to both pages using the &lt;link&gt; tag:\n<pre>&lt;link href=\"styles.css\" type=\"text\/css\" rel=\"stylesheet\"&gt;<\/pre>\n<\/li>\n<li>Verify that the styles take effect and that the .css file appears as a separate Dreamweaver tab in your document.<\/li>\n<\/ol>\n<\/div>\n<h2>Using Selectors<\/h2>\n<p>Selectors are like the strings on a marionette\u2014they connect the tags with the styles you want to apply. You can select all tags by writing the tag in a style statement and the styles in braces, e.g., p {font-family: Georgia;} selects all paragraphs and sets them in the font Georgia. But what if you want to style different paragraphs differently? In that case you can label the paragraph with an ID (use once on a page) or with a class (used multiple times).\u00a0Select the ID in CSS using a hash tag # and a class by preceding it with a dot.<\/p>\n<p>Pseudoclasses are a type of class that\u2019s built in to the HTML5 and does not need to be labeled by the designer. Example: p:nth-child(1) selects the first paragraph.<\/p>\n<\/div>\n<p>Another way to select tags for styling is to use the structure of the HTML. Example: you used an unordered list of bullet points to make a navigation menu, and you placed the list within a navigation or &lt;nav&gt; tag. You can select only that list by writing \u201cnav ul.\u201d Other lists on the page will not be affected.<\/p>\n<div class=\"tutorial-3-\u2022-styles\">\n<p>A great exercise on selectors is the \u201cCSS Diner\u201d at <a href=\"http:\/\/flukeout.github.io\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/flukeout.github.io<\/a>. To select one or more items out of several:<\/p>\n<table>\n<tbody>\n<tr style=\"background: whitesmoke\">\n<th colspan=\"3\">Methods of Selecting Tags for Styling<\/th>\n<\/tr>\n<tr>\n<td style=\"width: 60%;\"><strong><em>Selection method<\/em><\/strong><\/td>\n<td style=\"width: 20%;\"><strong><em>Example in HTML<\/em><\/strong><\/td>\n<td style=\"width: 20%;\"><strong><em>Example in CSS<\/em><\/strong><\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>Use an ID (for one item)<\/td>\n<td>&lt;p id=&#8221;para1&#8243;&gt;<\/td>\n<td>#para1 {}<\/td>\n<\/tr>\n<tr>\n<td>Use a class (for multiple items)<\/td>\n<td>&lt;p class=&#8221;para1&#8243;&gt;<\/td>\n<td>.para1 {}<\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>Use a pseudoselector (for first, second, or a repeating pattern of connected items, known as \u201cchildren\u201d)<\/td>\n<td>\u2014<br \/>\n(built into HTML5)<\/td>\n<td>p:nth-child(1)<br \/>\n1, 2, 3, \u2026,<br \/>\nodd, even<br \/>\n1n+3 (every 3 starting with 1st)<\/td>\n<\/tr>\n<tr>\n<td>Use the HTML structure, e.g., &lt;div&gt; with an &lt;img&gt; tag in it<\/td>\n<td>&lt;div&gt;&lt;img&gt;<\/td>\n<td>div img {}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>What to Style<\/h2>\n<p>Two demo files from Patrick Carey\u2019s textbook, <em>New Perspectives on HTML<\/em> (Thompson) show examples of how you can style text and color. (A third shows the web-safe palette.)<\/p>\n<p class=\"import-ListBullet\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image1-1.png\" width=\"768\" height=\"1066\" alt=\"This page demonstrates how different styles affect the appearance of Web page text. Enter your sample text in the box in the upper-right corner of this page. When you press the Tab key, the text will be copied to the Preview box. Set the styles for the preview text by entering or selecting the style value from the input boxes on the left and then pressing the Tab key. To apply the default style values, enter or select &quot;default&quot;. The style selections will be applied automatically to the preview text and the style code will be displayed in the box on the lower-right of the page. To reset all of the styles to their default values, click the Reset Styles button at the bottom of the page.\" class=\"aligncenter\" \/><\/p>\n<p><strong>demo_text_styles<\/strong><strong>.<\/strong> Notice all the characteristics of type that you can style. Some common ones include:<\/p>\n<ul>\n<li>font-family\u2014the typeface<\/li>\n<li>font-weight\u2014bold<\/li>\n<li>font-style\u2014italic<\/li>\n<\/ul>\n<p><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-1024x170.png\" alt=\"You define colors in HTML and XHTML using either a color name or a color value. HTML and XHTML support a list of 16 basic color names. Most browsers also support an extended set of color names. The following table lists these extended color names, along with RGB and hexadecimal values for each color. The sixteen color names supported by HTML and XHTML are highlighted in the table. Web-safe colors are displayed in a bold font.\" width=\"1024\" height=\"170\" class=\"aligncenter wp-image-33 size-large\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-1024x170.png 1024w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-300x50.png 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-768x128.png 768w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-1536x256.png 1536w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-2048x341.png 2048w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-65x11.png 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-225x37.png 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2-1-350x58.png 350w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p><strong>demo_color_names<\/strong><strong>.<\/strong>\u00a0A palette of the 140 named colors and four ways to specify them:<\/p>\n<ul>\n<li>named colors\u2014red, green, blue, lightblue, azure, chartreuse, \u2026 102 names<\/li>\n<li>rgb\u2014red, green, and blue values, scale 0\u2013255, e.g., color: rgb(255,0,0);<\/li>\n<li>rgba\u2014\u201ca\u201d adds the \u201calpha channel,\u201d or transparency, from 0-1.00, where 0 is completely invisible and 1.00 is opaque.<\/li>\n<li>hex\u20143 or 6 numbers and letters on a scale of 0-16, where 10=A, 11=B, etc. Difficult to comprehend if you are trying to figure out what color it is.<\/li>\n<\/ul>\n<h4>What to color<\/h4>\n<ul>\n<li>color: red; \u2014will color text<\/li>\n<li>background: red; \u2014colors objects, like \u201cfill\u201d in Illustrator or Photoshop<\/li>\n<\/ul>\n<h4>Space<\/h4>\n<ul>\n<li>margin: all around; margin: top bottom; margin: top right bottom left\u2014determines space around an object; margin: 0 auto will center an object if its width is specified and it&#8217;s a block-level element.<\/li>\n<li>padding: expands an object (including background color)<\/li>\n<\/ul>\n<figure id=\"attachment_187\" aria-describedby=\"caption-attachment-187\" style=\"width: 768px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins.jpg\" alt=\"\" width=\"768\" height=\"442\" class=\"wp-image-187\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins.jpg 1024w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins-300x173.jpg 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins-768x442.jpg 768w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins-65x37.jpg 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins-225x129.jpg 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4.1_Margins-350x201.jpg 350w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><figcaption id=\"caption-attachment-187\" class=\"wp-caption-text\">Demonstration showing the difference between margin, padding, border, and table cell spacing.<\/figcaption><\/figure>\n<h4>Size<\/h4>\n<ul>\n<li>width<\/li>\n<li>height<\/li>\n<\/ul>\n<p class=\"import-Normal\" style=\"text-align: center\"><img decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image3.jpg\" width=\"512px\" height=\"auto\" alt=\"image\" \/><\/p>\n<h2>Working with Fonts<\/h2>\n<p>Two ways to include an unusual or decorative font on a web page are to place the font on the server and access it using the @font-face rule, and use a Google or other free font.<\/p>\n<h3>Including a Font on Your Server<\/h3>\n<p>If you want to use an unusual font and you are unsure if users will have this font on their computers, you can put the font file on your server and link to it using the \u201c@font-face\u201d rule. In this example, the font candara.ttf was placed on the server in the same folder as the styles.css file and linked similar to a background image.<\/p>\n<p class=\"import-Normal\" style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image4.jpg\" width=\"350\" height=\"160\" alt=\"CSS code example: @font-face { font-family: Candara; src: url(candara.tff);\" class=\"alignnone\" \/><\/p>\n<div style=\"width: 100%;background: azure;margin: 12px auto;border: 1px dotted lightblue;padding: 12px\">\n<h3>Using a Google Font<\/h3>\n<p>Google has numerous free fonts available on its web site, <a class=\"rId11\" href=\"http:\/\/www.google.com\/fonts\">Google Fonts <em>[New Window]<\/em><\/a>. The font information can be linked to your web page using the &lt;link&gt; rule. To use a Google font:<\/p>\n<ol>\n<li class=\"import-Normal\">Browse the available fonts and add one you want to your collection.<\/li>\n<li class=\"import-Normal\">Access your font collection to get the link to the font and the syntax to cite the font.<\/li>\n<li class=\"import-Normal\">In this example, the font \u201cNova Flat\u201d was accessed:<\/li>\n<\/ol>\n<p style=\"padding-left: 40px\">Embed code:<\/p>\n<pre style=\"padding-left: 40px\">&lt;link href=\u201dhttps:\/\/fonts.googleapis.com\/css?family=Nova+Flat\u201d rel=\u201dstylesheet\u201d&gt;<\/pre>\n<ol start=\"4\">\n<li>To use the font:<\/li>\n<\/ol>\n<pre class=\"import-Normal\" style=\"padding-left: 40px\">font-family: \u2018Nova Flat\u2019, cursive;<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<table style=\"margin: 0 auto;width: 80%\">\n<tbody>\n<tr>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image5.jpg\" width=\"312\" height=\"682\" alt=\"Example of the font face Nova Flat visualization on Google Fonts\" class=\"alignnone\" \/><\/td>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image6.jpg\" width=\"424\" height=\"1196\" alt=\"Example of embed option for font faces on Google Fonts\" class=\"alignnone\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Tables<\/h2>\n<p>Tables are a nice way to organize information that&#8217;s easy for readers to comprehend. Basic table tags are table &lt;table&gt;, table rows &lt;tr&gt;, and table data &lt;td&gt; which refers to the cells and therefore the columns. (There is no tag for table columns, they are determined by the cells.)<\/p>\n<p>Various styles can be applied to the table, tr, and td tags including the border, color (of font), and background, including an image background. \u201cPseudoselectors\u201d including nth-child(odd) can be used to shade alternating rows to differentiate them more imaginatively than with the traditional borders.<\/p>\n<h3 class=\"import-ListBullet\">Anatomy of a Table<\/h3>\n<table style=\"margin: 0 auto;background: whitesmoke;width: 67%\">\n<tbody>\n<tr>\n<td><strong>&lt;table&gt;<\/strong><\/td>\n<td>\n<p style=\"text-align: center\"><strong>&lt;td&gt;<\/strong><\/p>\n<\/td>\n<td>\n<p style=\"text-align: center\"><strong>&lt;td&gt;<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><strong>&lt;tr&gt;<\/strong><\/td>\n<td>Row 1, Column 1<\/td>\n<td>Row 1, Column 2<\/td>\n<\/tr>\n<tr>\n<td><strong>&lt;tr&gt;<\/strong><\/td>\n<td>Row 2, Column 1<\/td>\n<td>Row 2, Column 2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"import-ListBullet\" style=\"margin-left: 72px;margin-right: 72px\"><em>Sample table (above) and the tags for the table &lt;table&gt;, rows &lt;tr&gt;, and columns (cells, &lt;td&gt;). Columns are determined by the cells. Code below.<\/em><\/p>\n<p>&nbsp;<\/p>\n<div class=\"textbox shaded\" style=\"background: whitesmoke;width: 67%;margin: 0 auto\">\n<p>&lt;table&gt;<\/p>\n<p style=\"padding-left: 40px\">&lt;tr&gt;<\/p>\n<p style=\"padding-left: 80px\">&lt;td&gt;Row 1, Column 1&lt;\/td&gt;&lt;td&gt;Row 1, Column 2&lt;\/td&gt;<\/p>\n<p style=\"padding-left: 40px\">&lt;\/tr&gt;<\/p>\n<p style=\"padding-left: 40px\">&lt;tr&gt;<\/p>\n<p style=\"padding-left: 80px\">&lt;td&gt;Row 2, Column 1&lt;\/td&gt;&lt;td&gt;Row 2, Column 2&lt;\/td&gt;<\/p>\n<p style=\"padding-left: 40px\">&lt;\/tr&gt;<\/p>\n<p>&lt;\/table&gt;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<table style=\"margin: 0 auto;width: 80%\">\n<tbody>\n<tr style=\"background: whitesmoke\">\n<th colspan=\"2\">Table Tags<\/th>\n<\/tr>\n<tr>\n<th>Tag<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>&lt;table&gt;&lt;\/table&gt;<\/td>\n<td>table<\/td>\n<\/tr>\n<tr>\n<td>&lt;tr&gt;&lt;\/tr&gt;<\/td>\n<td>table row<br \/>\nmerge\u2014number of columns to span<\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>&lt;td&gt;&lt;\/td&gt;<\/td>\n<td>table data\u2014columns<br \/>\n\u2022 there is no &#8220;column&#8221; tag because the columns are determined by the cells<\/td>\n<\/tr>\n<tr>\n<td>&lt;th&gt;&lt;\/th&gt;<\/td>\n<td>table header<br \/>\n\u2022 first row(s), type will be bold centered<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table style=\"margin: 0 auto;width: 80%\">\n<tbody>\n<tr style=\"background: whitesmoke\">\n<th colspan=\"2\">CSS Styles Useful to Table Tags<\/th>\n<\/tr>\n<tr>\n<td><strong>Style<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>border<\/td>\n<td>px color, e.g., border: 1px solid gray;<\/td>\n<\/tr>\n<tr>\n<td>padding<\/td>\n<td>text inset, e.g., padding: 12px;<\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>spacing<\/td>\n<td>space between cells<\/td>\n<\/tr>\n<tr>\n<td>background: color;<br \/>\nbackground-image: url(image.jpg);<\/td>\n<td>color of table, rows, and\/or cells; could include background image;<br \/>\n\u2022 color: rgb(0,0,0);<br \/>\n\u2022 color: #fff;<br \/>\n\u2022 background: (url &#8220;image.jpg&#8221;);<\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>pseudo-selectors<br \/>\n:nth-child(1)<br \/>\n:nth-child(odd)<br \/>\n:nth-child(even)<br \/>\n:first-child<br \/>\n:last-child<br \/>\n:nth-child(3n)<\/td>\n<td>first item in a group of multiple<br \/>\nall odd-numbered items<br \/>\nall even-numbered items<br \/>\nfirst item<br \/>\nlast item<br \/>\nevery 3rd item<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style=\"width: 100%;background: azure;margin: 12px auto;border: 1px dotted lightblue;padding: 12px\">\n<h3>Importing Table Text<\/h3>\n<ol>\n<li>Import the table text (table.txt) into Dreamweaver: File &gt; Import &gt; Tabular Data.<\/li>\n<li>Style the table by:<\/li>\n<\/ol>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>inserting an embedded or global &lt;style&gt; tag in the &lt;head&gt;<\/li>\n<li>selecting the table elements (&lt;table&gt;, etc., see Table 1 below)<\/li>\n<li>applying the specifications you want (Table 2 below)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<p>&nbsp;<\/p>\n<table style=\"margin: 0 auto;width: 90%\">\n<tbody>\n<tr style=\"background: lightblue\">\n<th colspan=\"3\">Russian Fairytale Boxes<\/th>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<th>Box<\/th>\n<th>Characters<\/th>\n<th>English Counterpart<\/th>\n<\/tr>\n<tr style=\"background: azure\">\n<td>The Grey Wolf<\/td>\n<td>Ivan Tsarevitch, Helen the Beautiful, the Grey Wolf<\/td>\n<td>none<\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>The Horse with the Golden Mane<\/td>\n<td>Ivan Tsarevitch and the Horse with the Golden Mane<\/td>\n<td>The Magic Pony<\/td>\n<\/tr>\n<tr style=\"background: azure\">\n<td>The Firebird<\/td>\n<td>Ivan Tsarevitch and the Firebird<\/td>\n<td>The Phoenix<\/td>\n<\/tr>\n<tr style=\"background: whitesmoke\">\n<td>Father Frost<\/td>\n<td>Father Frost, the Snow Queen, and a troika of horses<\/td>\n<td>Santa Clause<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"author":6,"menu_order":3,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-38","chapter","type-chapter","status-publish","hentry"],"part":3,"_links":{"self":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/users\/6"}],"version-history":[{"count":29,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters\/38\/revisions"}],"predecessor-version":[{"id":396,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters\/38\/revisions\/396"}],"part":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters\/38\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapter-type?post=38"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/contributor?post=38"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/license?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}