{"id":112,"date":"2020-08-01T20:08:23","date_gmt":"2020-08-02T00:08:23","guid":{"rendered":"https:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/chapter\/tutorial-6-%e2%80%a2-image-optimization\/"},"modified":"2021-02-14T19:09:23","modified_gmt":"2021-02-15T00:09:23","slug":"tutorial-5-image-optimization","status":"publish","type":"chapter","link":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/chapter\/tutorial-5-image-optimization\/","title":{"raw":"Tutorial 5 \u2022 Image Optimization","rendered":"Tutorial 5 \u2022 Image Optimization"},"content":{"raw":"Bitmapped images are use-specific, meaning the resolution has to be set for the intended use and reproduction size, so as to avoid \u201cthe jaggies,\u201d or pixelization, and also to avoid excessively large file size, which slows output for print and download time on the web.\r\n\r\nA good place to start thinking about web images is whether the image should occupy a full page, half page, or quarter page. Resolution for web should be 72 ppi. Higher resolution does not produce finer detail unless the image is to be enlarged, e.g., if a smaller image is linked to a larger view.\r\n\r\nTransparency is often useful for web images. GIF and PNG file types support transparency, but not JPEG.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"\" align=\"aligncenter\" width=\"512\"]<img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image1.jpeg\" width=\"512\" height=\"auto\" alt=\"image\" \/> Photoshop\u2019s Camera Raw open dialog box.[\/caption]\r\n\r\n<div style=\"background: azure;border: 1px solid lightblue;width: 100%;padding: 12px\">\r\n<h2>Let\u2019s Optimize Some Images<\/h2>\r\n<h4>DNG Images<\/h4>\r\n<ol>\r\n \t<li>In Photoshop, simultaneously open the three .DNG \u201cdigital negative\u201d images, which will open as Camera Raw.<\/li>\r\n \t<li>Note that the images are a bracketed exposure series of \u00b1\u2153 exposure value (EV). When making an exposure, bracketing only takes a few extra seconds and enables you to compare exposures later on a large screen.<\/li>\r\n \t<li>Note that the three images can be identically cropped if they are all selected when the cropped area is drawn.<\/li>\r\n \t<li>Final image size and resolution can be set in the blue link below the preview.<\/li>\r\n \t<li>Select all 3 images, flip 180\u00b0, and crop to a square 1024\u00d71024 px at 72 ppi, and open.<\/li>\r\n \t<li>Choose File &gt; Save for Web &gt; JPEG. Note that the dialog box includes settings for quality and size, and also displays the final file size and expected download time at different network speeds.<\/li>\r\n<\/ol>\r\n[caption id=\"\" align=\"aligncenter\" width=\"512\"]<img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2.jpeg\" width=\"512\" height=\"auto\" alt=\"image\" \/> Photoshop\u2019s Save for Web dialog box.[\/caption]\r\n<h4>PNG Image<\/h4>\r\n<ol>\r\n \t<li>Open the image \u201c4_BlackFlowers.jpg.\u201d<\/li>\r\n \t<li>With the Circular Selection Tool, hold SHIFT+OPT and draw a circle around the box, starting from the centre. Reposition if necessary.<\/li>\r\n \t<li>In the selection, right-click or CNTRL-click \u201cNew Layer from Cut.\u201d This places the box on a new layer, leaving the Background empty.<\/li>\r\n \t<li>In the Layers palette (Window &gt; Layers), delete the Background layer.<\/li>\r\n \t<li>File &gt; Save for Web, select PNG-24 format, and check Transparency. The background should show as a checkered pattern.<\/li>\r\n<\/ol>\r\n<table style=\"border-collapse: collapse;width: 80%;margin: 0 auto\" border=\"0\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.jpg\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.jpg\" alt=\"\" width=\"1024\" height=\"1024\" class=\"aligncenter size-full wp-image-116\" \/><\/a><\/td>\r\n<td style=\"width: 50%\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.png\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.png\" alt=\"\" width=\"512\" height=\"512\" class=\"aligncenter size-full wp-image-117\" \/><\/a><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;text-align: center\"><em>JPEG image without transparency<\/em><\/td>\r\n<td style=\"width: 50%;text-align: center\"><em>PNG-24 image with transparency<\/em><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<h4>Place in Web Page<\/h4>\r\n<ol>\r\n \t<li>Place both images into a web page styled with body {background: gray;}.<\/li>\r\n \t<li>Note that the background of the PNG image is transparent while that of the JPG is not.<\/li>\r\n<\/ol>\r\n<\/div>\r\n<h2>Images as Links<\/h2>\r\nImages can be linked either to larger versions of themselves or to other HTML documents. Simply surround the image with a link tag (&lt;a href=\"filename\"&gt;).\r\n\r\nUnlike a text link, with its default blue color and underline, an image link will not look any different from an unlinked image. However the pseudo-class \u201c:hover\u201d can be used to style the linked image differently when the mouse is over it. Some common styles include putting a border (e.g., \u201cborder: 1px solid grey;\u201d) or drop-shadow (\u201cbox-shadow: 2px 3px 6px grey;\u201d) around the image, reducing the opacity (\u201copacity: 0.50;\u201d), expanding the image slightly (\u201ctransform: scale(1.05);\u201d) or moving the image slightly (\u201ctransform: translateY(5px);\u201d). All of these effects can be faded in by adding the \u201ctransition\u201d style, specifying the style to be transitioned and the time in seconds, e.g., \u201ctransition: scale 0.5s;\u201d.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_331\" align=\"aligncenter\" width=\"768\"]<a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image.jpg\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-1024x660.jpg\" alt=\"Linked image\" width=\"768\" height=\"495\" class=\"wp-image-331\" style=\"border: 1px solid grey\" \/><\/a> Image used as a link to a larger version of itself. The image is styled with a \u201chover\u201d tag so a drop-shadow appears when the mouse is over the image.[\/caption]\r\n<h2>Captioning with the Figure and Figcaption Tags<\/h2>\r\nUsing the &lt;figure&gt; tag, images can be grouped with a caption written in the &lt;figcaption&gt; tag. All three tags can be styled for size, positioning, margin and padding, and text wrap (float).\r\n\r\n&lt;figure&gt;\r\n&lt;img src=\"image.jpg\" \/&gt;\r\n&lt;figcaption&gt;Figure 1.&lt;\/figcaption&gt;\r\n&lt;\/figure&gt;\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_316\" align=\"aligncenter\" width=\"768\"]<a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html.jpg\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-1024x686.jpg\" alt=\"Figure and figcaption tags\" width=\"768\" height=\"514\" class=\"wp-image-316\" style=\"border: 1px solid grey\" \/><\/a> The figure tag used to group an image with a caption.[\/caption]\r\n<h2>Grouping Photos with Divs or Tables<\/h2>\r\nTwo or more photos can be grouped together with &lt;div&gt; or &lt;table&gt; tags. The div width should be set to equal the sum of the image widths, including an allowance for any borders or margin around the images. Once grouped, the div can be styled by centering and placing spacing around it. A table can be constructed with one photo per cell (&lt;td&gt;) to create horizontal and vertical matrixes of images.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_321\" align=\"aligncenter\" width=\"768\"]<a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-scaled.jpg\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-1024x632.jpg\" alt=\"Grouping images with a div tag\" width=\"768\" height=\"474\" class=\"wp-image-321\" style=\"border: 1px solid grey\" \/><\/a> A div or division with id \u201cimage-gallery\u201d is used to group 3 photos in a row and center them in the page.[\/caption]\r\n<h2>Arranging Photos with the Flexible Box and Grid Layouts<\/h2>\r\nThe relatively new \u201cflexible box\u201d and \u201cgrid\u201d layouts are useful for arranging multiple images on web pages.\r\n\r\nWhen a div is styled with \u201cdisplay: flex;\u201d and accompanying \u201calign-items\u201d and related styles, the items in the div will arrange themselves on the page. Additional items can easily be added, such as more photos or documents.\r\n\r\nSimilarly, the \u201cgrid\u201d layout can be used to specify columns, rows, or grid regions on the page.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_324\" align=\"aligncenter\" width=\"768\"]<a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-scaled.jpg\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-1024x577.jpg\" alt=\"CSS grid layout\" width=\"768\" height=\"433\" class=\"wp-image-324\" style=\"border: 1px solid grey\" \/><\/a> The grid layout is helpful for arranging images or other tags. In this case, the style \"display: grid;\" creates the grid, which is defined with 3 columns and two rows.[\/caption]\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_326\" align=\"aligncenter\" width=\"768\"]<a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-scaled.jpg\"><img src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-1024x570.jpg\" alt=\"Flexible box layout\" width=\"768\" height=\"427\" class=\"wp-image-326\" style=\"border: 1px solid grey\" \/><\/a> The flexible box layout, style \"display: flex;\" is helpful in arranging images and other tags on the screen.[\/caption]","rendered":"<p>Bitmapped images are use-specific, meaning the resolution has to be set for the intended use and reproduction size, so as to avoid \u201cthe jaggies,\u201d or pixelization, and also to avoid excessively large file size, which slows output for print and download time on the web.<\/p>\n<p>A good place to start thinking about web images is whether the image should occupy a full page, half page, or quarter page. Resolution for web should be 72 ppi. Higher resolution does not produce finer detail unless the image is to be enlarged, e.g., if a smaller image is linked to a larger view.<\/p>\n<p>Transparency is often useful for web images. GIF and PNG file types support transparency, but not JPEG.<\/p>\n<p>&nbsp;<\/p>\n<figure style=\"width: 512px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image1.jpeg\" width=\"512\" height=\"auto\" alt=\"image\" \/><figcaption class=\"wp-caption-text\">Photoshop\u2019s Camera Raw open dialog box.<\/figcaption><\/figure>\n<div style=\"background: azure;border: 1px solid lightblue;width: 100%;padding: 12px\">\n<h2>Let\u2019s Optimize Some Images<\/h2>\n<h4>DNG Images<\/h4>\n<ol>\n<li>In Photoshop, simultaneously open the three .DNG \u201cdigital negative\u201d images, which will open as Camera Raw.<\/li>\n<li>Note that the images are a bracketed exposure series of \u00b1\u2153 exposure value (EV). When making an exposure, bracketing only takes a few extra seconds and enables you to compare exposures later on a large screen.<\/li>\n<li>Note that the three images can be identically cropped if they are all selected when the cropped area is drawn.<\/li>\n<li>Final image size and resolution can be set in the blue link below the preview.<\/li>\n<li>Select all 3 images, flip 180\u00b0, and crop to a square 1024\u00d71024 px at 72 ppi, and open.<\/li>\n<li>Choose File &gt; Save for Web &gt; JPEG. Note that the dialog box includes settings for quality and size, and also displays the final file size and expected download time at different network speeds.<\/li>\n<\/ol>\n<figure style=\"width: 512px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/image2.jpeg\" width=\"512\" height=\"auto\" alt=\"image\" \/><figcaption class=\"wp-caption-text\">Photoshop\u2019s Save for Web dialog box.<\/figcaption><\/figure>\n<h4>PNG Image<\/h4>\n<ol>\n<li>Open the image \u201c4_BlackFlowers.jpg.\u201d<\/li>\n<li>With the Circular Selection Tool, hold SHIFT+OPT and draw a circle around the box, starting from the centre. Reposition if necessary.<\/li>\n<li>In the selection, right-click or CNTRL-click \u201cNew Layer from Cut.\u201d This places the box on a new layer, leaving the Background empty.<\/li>\n<li>In the Layers palette (Window &gt; Layers), delete the Background layer.<\/li>\n<li>File &gt; Save for Web, select PNG-24 format, and check Transparency. The background should show as a checkered pattern.<\/li>\n<\/ol>\n<table style=\"border-collapse: collapse;width: 80%;margin: 0 auto\">\n<tbody>\n<tr>\n<td style=\"width: 50%\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.jpg\" alt=\"\" width=\"1024\" height=\"1024\" class=\"aligncenter size-full wp-image-116\" \/><\/a><\/td>\n<td style=\"width: 50%\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.png\" alt=\"\" width=\"512\" height=\"512\" class=\"aligncenter size-full wp-image-117\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers.png 512w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers-300x300.png 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers-150x150.png 150w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers-65x65.png 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers-225x225.png 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/4_BlackFlowers-350x350.png 350w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%;text-align: center\"><em>JPEG image without transparency<\/em><\/td>\n<td style=\"width: 50%;text-align: center\"><em>PNG-24 image with transparency<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Place in Web Page<\/h4>\n<ol>\n<li>Place both images into a web page styled with body {background: gray;}.<\/li>\n<li>Note that the background of the PNG image is transparent while that of the JPG is not.<\/li>\n<\/ol>\n<\/div>\n<h2>Images as Links<\/h2>\n<p>Images can be linked either to larger versions of themselves or to other HTML documents. Simply surround the image with a link tag (&lt;a href=&#8221;filename&#8221;&gt;).<\/p>\n<p>Unlike a text link, with its default blue color and underline, an image link will not look any different from an unlinked image. However the pseudo-class \u201c:hover\u201d can be used to style the linked image differently when the mouse is over it. Some common styles include putting a border (e.g., \u201cborder: 1px solid grey;\u201d) or drop-shadow (\u201cbox-shadow: 2px 3px 6px grey;\u201d) around the image, reducing the opacity (\u201copacity: 0.50;\u201d), expanding the image slightly (\u201ctransform: scale(1.05);\u201d) or moving the image slightly (\u201ctransform: translateY(5px);\u201d). All of these effects can be faded in by adding the \u201ctransition\u201d style, specifying the style to be transitioned and the time in seconds, e.g., \u201ctransition: scale 0.5s;\u201d.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_331\" aria-describedby=\"caption-attachment-331\" style=\"width: 768px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-1024x660.jpg\" alt=\"Linked image\" width=\"768\" height=\"495\" class=\"wp-image-331\" style=\"border: 1px solid grey\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-1024x660.jpg 1024w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-300x193.jpg 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-768x495.jpg 768w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-1536x991.jpg 1536w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-65x42.jpg 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-225x145.jpg 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image-350x226.jpg 350w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/linked-image.jpg 1870w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><figcaption id=\"caption-attachment-331\" class=\"wp-caption-text\">Image used as a link to a larger version of itself. The image is styled with a \u201chover\u201d tag so a drop-shadow appears when the mouse is over the image.<\/figcaption><\/figure>\n<h2>Captioning with the Figure and Figcaption Tags<\/h2>\n<p>Using the &lt;figure&gt; tag, images can be grouped with a caption written in the &lt;figcaption&gt; tag. All three tags can be styled for size, positioning, margin and padding, and text wrap (float).<\/p>\n<p>&lt;figure&gt;<br \/>\n&lt;img src=&#8221;image.jpg&#8221; \/&gt;<br \/>\n&lt;figcaption&gt;Figure 1.&lt;\/figcaption&gt;<br \/>\n&lt;\/figure&gt;<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_316\" aria-describedby=\"caption-attachment-316\" style=\"width: 768px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-1024x686.jpg\" alt=\"Figure and figcaption tags\" width=\"768\" height=\"514\" class=\"wp-image-316\" style=\"border: 1px solid grey\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-1024x686.jpg 1024w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-300x201.jpg 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-768x514.jpg 768w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-1536x1028.jpg 1536w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-2048x1371.jpg 2048w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-65x44.jpg 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-225x151.jpg 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/figure-demo_html-350x234.jpg 350w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><figcaption id=\"caption-attachment-316\" class=\"wp-caption-text\">The figure tag used to group an image with a caption.<\/figcaption><\/figure>\n<h2>Grouping Photos with Divs or Tables<\/h2>\n<p>Two or more photos can be grouped together with &lt;div&gt; or &lt;table&gt; tags. The div width should be set to equal the sum of the image widths, including an allowance for any borders or margin around the images. Once grouped, the div can be styled by centering and placing spacing around it. A table can be constructed with one photo per cell (&lt;td&gt;) to create horizontal and vertical matrixes of images.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_321\" aria-describedby=\"caption-attachment-321\" style=\"width: 768px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-1024x632.jpg\" alt=\"Grouping images with a div tag\" width=\"768\" height=\"474\" class=\"wp-image-321\" style=\"border: 1px solid grey\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-1024x632.jpg 1024w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-300x185.jpg 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-768x474.jpg 768w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-1536x948.jpg 1536w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-2048x1264.jpg 2048w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-65x40.jpg 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-225x139.jpg 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/div-group-350x216.jpg 350w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><figcaption id=\"caption-attachment-321\" class=\"wp-caption-text\">A div or division with id \u201cimage-gallery\u201d is used to group 3 photos in a row and center them in the page.<\/figcaption><\/figure>\n<h2>Arranging Photos with the Flexible Box and Grid Layouts<\/h2>\n<p>The relatively new \u201cflexible box\u201d and \u201cgrid\u201d layouts are useful for arranging multiple images on web pages.<\/p>\n<p>When a div is styled with \u201cdisplay: flex;\u201d and accompanying \u201calign-items\u201d and related styles, the items in the div will arrange themselves on the page. Additional items can easily be added, such as more photos or documents.<\/p>\n<p>Similarly, the \u201cgrid\u201d layout can be used to specify columns, rows, or grid regions on the page.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_324\" aria-describedby=\"caption-attachment-324\" style=\"width: 768px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-1024x577.jpg\" alt=\"CSS grid layout\" width=\"768\" height=\"433\" class=\"wp-image-324\" style=\"border: 1px solid grey\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-1024x577.jpg 1024w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-300x169.jpg 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-768x433.jpg 768w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-1536x865.jpg 1536w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-2048x1154.jpg 2048w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-65x37.jpg 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-225x127.jpg 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-grid-350x197.jpg 350w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><figcaption id=\"caption-attachment-324\" class=\"wp-caption-text\">The grid layout is helpful for arranging images or other tags. In this case, the style &#8220;display: grid;&#8221; creates the grid, which is defined with 3 columns and two rows.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_326\" aria-describedby=\"caption-attachment-326\" style=\"width: 768px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.ryerson.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-1024x570.jpg\" alt=\"Flexible box layout\" width=\"768\" height=\"427\" class=\"wp-image-326\" style=\"border: 1px solid grey\" srcset=\"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-1024x570.jpg 1024w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-300x167.jpg 300w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-768x427.jpg 768w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-1536x855.jpg 1536w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-2048x1139.jpg 2048w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-65x36.jpg 65w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-225x125.jpg 225w, https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-content\/uploads\/sites\/133\/2020\/08\/gallery-flex-350x195.jpg 350w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><figcaption id=\"caption-attachment-326\" class=\"wp-caption-text\">The flexible box layout, style &#8220;display: flex;&#8221; is helpful in arranging images and other tags on the screen.<\/figcaption><\/figure>\n","protected":false},"author":6,"menu_order":5,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-112","chapter","type-chapter","status-publish","hentry"],"part":3,"_links":{"self":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters\/112","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":23,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters\/112\/revisions"}],"predecessor-version":[{"id":335,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapters\/112\/revisions\/335"}],"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\/112\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/pressbooks\/v2\/chapter-type?post=112"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/contributor?post=112"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.library.torontomu.ca\/webdesignlab\/wp-json\/wp\/v2\/license?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}