Web Design
Lecture & Discussion:
Colors and Images
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
CSS color Property
On digital screens, all colors are created using some combination of
CSS color Property
On digital screens, all colors are created using some combination of red
CSS color Property
On digital screens, all colors are created using some combination of red, green
CSS color Property
On digital screens, all colors are created using some combination of red, green, and blue color values.
CSS color Property
CSS color Property
CSS color Property
CSS color Property
CSS color Property
CSS color Property
CSS color Property
If you use a magnifying glass🔍🔍🔍 (or just push your face right up against your screen), you might be able to see thousands of tiny red, green, and blue rectangles.
CSS color Property
If you use a magnifying glass🔍🔍🔍 (or just push your face right up against your screen), you might be able to see thousands of tiny red, green, and blue rectangles.
These are picture elements, or pixels.
CSS color Property
CSS color Property
In HTML and CSS, we can control colors using four different color declarations:
RGB
Hex
HSL
CSS Color Names
CSS color Property
RGB (Red, Green, Blue) color: rgb(0,0,0);
Hex (Hexadecimal) color: #000000;
HSL (Hue, Saturation, Lightness) color: hsl(0%,100%,50%);
CSS Color Names (140) color: black;
CSS color Property
RGB (0-255,0-255,0-255)
CSS color Property
RGB (0-255,0-255,0-255)
Black color: rgb(0,0,0);
Red color: rgb(255,0,0);
Orange color: rgb(255,165,0);
Yellow color: rgb(255,255,0);
Lime color: rgb(0,255,0);
Cyan color: rgb(0,255,255);
Blue color: rgb(0,0,255);
White color: rgb(255,255,255);
CSS color Property
RGB (0%-100%,0%-100%,0%-100%)
CSS color Property
RGB (0%-100%,0%-100%,0%-100%)
Black color: rgb(0%,0%,0%);
Red color: rgb(100%,0%,0%);
Orange color: rgb(100%,50%,0%);
Yellow color: rgb(100%,100%,0%);
Lime color: rgb(0%,100%,0%);
Cyan color: rgb(0%,100%,100%);
Blue color: rgb(0%,0%,100%);
White color: rgb(100%,100%,100%);
CSS color Property
Hex (#FFFFFF) 0 1 2 3 4 5 6 7 8 9 A B C D E F
CSS color Property
Hex (#FFFFFF) 0 1 2 3 4 5 6 7 8 9 A B C D E F
Hexadecimal is a numeral system with a base of 16.
CSS color Property
Hex (#FFFFFF) 0 1 2 3 4 5 6 7 8 9 A B C D E F
The decimal system (base 10) only allows us to define 100 values using two digits (00 thru 99).
But the hexadecimal system (base 16) allows us to define 256 values using two digits (00 thru ff).
CSS color Property
Hex (#FFFFFF) 0 1 2 3 4 5 6 7 8 9 A B C D E F
0–9 represent values zero to nine
A represents the value ten
B represents the value eleven
C represents the value twelve
D represents the value thirteen
E represents the value fourteen
F represents the value fifteen
CSS color Property
Hexadecimal code in popular culture. The Martian (dir. Ridley Scott, 2015)
CSS color Property
Hexadecimal code in popular culture. The Martian (dir. Ridley Scott, 2015)
If you watched the 2015 film The Martian, �with Matt Damon, you’ll remember that �Damon’s character uses hexadecimal code �to send messages to NASA from Mars using �a simple visual communication system.
CSS color Property
Hexadecimal code in popular culture. The Martian (dir. Ridley Scott, 2015)
So, learning the hexadecimal system �is not only good for defining colors �on the Web, but it will also be useful �if you ever get trapped on Mars!
CSS color Property
Hex (#FFFFFF) 0 1 2 3 4 5 6 7 8 9 A B C D E F
CSS color Property
Hex (#FFFFFF) 0 1 2 3 4 5 6 7 8 9 A B C D E F
Black color: #000000;
Red color: #ff0000;
Orange color: #ffa500;
Yellow color: #ffff00;
Lime color: #00ff00;
Cyan color: #00ffff;
Blue color: #0000ff;
White color: #ffffff;
CSS color Property
RGB and Hex are two different ways to specify color on the web, but they are still the same color model.
CSS color Property
HSL (0-360, 0-100%, 0-100%)
Hue: Where the value is on the color spectrum
Saturation: Colorfulness
Lightness: Brightness
CSS color Property
Unlike RGB and Hex, HSL is a different color model.
CSS color Property
HSL (0-360, 0-100%, 0-100%)
Black color: hsl(0,0%,0%);
Red color: hsl(0,100%,50%);
Orange color: hsl(30,100%,50%);
Yellow color: hsl(60,100%,50%);
Lime color: hsl(120,100%,50%);
Cyan color: hsl(180,100%,50%);
Blue color: hsl(240,100%,50%);
White color: hsl(0,0%,100%);
CSS color Property
The easiest way to define colors in CSS �is to just use basic color names.
CSS color Property
CSS Color Names (140)
Black color: black;
Red color: red;
Orange color: orange;
Yellow color: yellow;
Lime color: limegreen;
Cyan color: cyan;
Blue color: blue;
White color: white;
CSS color Property
Here is a helpful color palette “cheatsheet” that shows you all of the CSS named colors – if you click on any of the colors you can see its CSS name value, as well as the RGB hexadecimal values.
CSS color Property
CSS Color Names (140)
https://www.w3schools.com/colors/colors_names.asp
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
Using the Eyedropper Tool �along with the Color Picker�in Adobe Photoshop is an �easy way to match color �values from photographs �or other references.
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
HTML <img> Tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End <img> tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End <img> tag
HTML <img> Tag
<img src="img/icon.png" alt="Image icon" title="Image Icon">
<img> tag
Start <img> tag
Source attribute
Path to file
Alternate attribute
Alternate text
Title attribute
Image title
End <img> tag
Images - Common Mistake
<img src="file:///Users/ianbesler/Desktop/img/icon.png">
Images - Common Mistake
<img src="file:///Users/ianbesler/Desktop/img/icon.png">
If you ever see the name prefix “file:” in your markup, it means that the HTML document will be looking for a document on the user’s local directory (and it won’t be there).
Images - Common Mistake
<img src="file:///Users/ianbesler/Desktop/img/icon.png">
<img src="img/icon.png">
Remember that our location specifications in markup are relational. So only apply file directions based on the document you’re currently working in (which has a folder called "img" in the same directory).
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
Image File Formats
Image File Formats
Image File Formats
Image File Formats
Image File Formats
Image File Formats
JPEG
Good for real-world imagery (photographs)
GIF
Bad for photos, better for digital �imagery (logos, animations)
Image File Formats
Image File Formats
Image File Formats
PNG
Can handle transparency gradients
GIF
Can’t handle transparency gradients
Image File Formats
Image File Formats
Image File Formats
Raster
Gets pixelated when it scales-up
Vector
Doesn’t get pixelated when it scales-up
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS background Property
CSS background Property
The CSS background-color: property is just one way to control the background of an HTML element.
CSS background Property
The CSS background-color: property is just one way to control the background of an HTML element.
We can also apply images to the background of an HTML element using the CSS background-image: property.
CSS background Property
http://www.homepage.com
CSS background Property
Let’s apply the CSS background-image: property to the HTML body selector in our CSS stylesheet to add some imagery to our website.
http://www.homepage.com
CSS background Property
body {
}
CSS background Property
body {
background-image: url("../img/cat.gif");
}
CSS background Property
http://www.homepage.com
CSS background Property
http://www.homepage.com
CSS background Property
http://www.homepage.com
This looks great! Notice that the image �is displayed at its normal size, but that �the web browser automatically tiles �and repeats the image to fill the �entire background.
CSS background Property
http://www.homepage.com
But what if we don’t want the �background image to tile and �repeat endlessly? Then we need �to use the CSS background-repeat: �property.
CSS background Property
body {
background-image: url("../img/cat.gif");
}
CSS background Property
body {
background-image: url("../img/cat.gif");
background-repeat: no-repeat;
}
CSS background Property
http://www.homepage.com
CSS background Property
http://www.homepage.com
OK… The background image no longer tiles and repeats, but it still displays at its normal width and height. The web browser automatically places the image in the top, left corner of the web page.
CSS background Property
http://www.homepage.com
If we want to make the background image �cover the entire background of the web page, �Then we need to adjust the CSS background-size: �property.
CSS background Property
body {
background-image: url("../img/cat.gif");
background-repeat: no-repeat;
}
CSS background Property
body {
background-image: url("../img/cat.gif");
background-repeat: no-repeat;
background-size: cover;
}
CSS background Property
http://www.homepage.com
CSS background Property
http://www.homepage.com
Awesome! The CSS background-size: cover; �declaration will automatically scale the image �to cover the entire background of the web page.
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
CSS color Property
RGB, Hex, HSL, CSS Color Names
Eyedropper Tool and Color Picker
HTML <img> tag
Image File Formats
CSS background property
Web Design is an open-source learning resource.
Class material developed by Ian Besler.�
Licensed under a Creative Commons�Attribution-NonCommercial-ShareAlike�4.0 International License.