top of page

09.10.2018: One Lesson of Coding


Today's soundtrack is MGMT: Little Dark Age, which kind of sounds like what I'd imagine a collaboration between Shiny Toy Guns and Modest Mouse might sound like.

This evening, I'm learning how to size images using CSS with the freeCodeCamp lessons.

In the same way that we can make font classes with CSS, we can use CSS to make image classes that control the width of images so that we get a consistent look on our websites.

Inside of our "style" element, we insert a new line that starts with a period and then has the name of the class we want to create; we put in a space and a left curly bracket, start a new line, specify the pixels of width followed by a semicolon, jump down another line, and use a closing right curly bracket.

<style>

.large-image {

width: 400px;

}

< /style>

To apply this class to an image, inside of its opening "img" tag, we include the desired class title.

< img class="large-image" src="https://www.imagesource.com/image.jpg" alt="A random image>

bottom of page