Styling & Color
Lesson Number 11, September 19, 2014
Due For This Class
- Read Chapter 8 in White Space Is Not Your Enemy (pg 114 - 134)
- Read WebAIM's Article on Color-Blindness (about 5 minutes)
- Read Smashing Magazine's series on Color Theory (start here)
- Read Contrast is King
- Pick three colors to use on your Project Portfolio. You can use a color scheme generator (a few are listed below), or draw inspiration from other sources.
Lesson Breakdown
- What colors did you choose for your website? Why?
- Adding color to your website.
- Using color to help create a visual heirarchy / create calls to action
- Color has meaning - we all know what the colors in this graphic represent ... so, what do you think happened when a Papa John's used colors in an unexpected way?
- Discovering layout
Cool Color Tools
There are so many great tools for playing with color online, choosing color schemes, and just generally discovering color.
- Colour Co (this is really awesome - allows you to see color schemes directly in your browser)
- What the Hex (I am horribly bad at this game)
- Color Hex (insert a hex code and learn all kinds of info about it)
- 0 to 255 (pick a color and get a range of that color shaded from lightest to darkest)
- Hex Clock
In-Class Activity
- Open your project-portfolio in Brackets. We will be editing your index.html file, so double-click to open that and edit it.
- Create a new folder in your project and name it
css
. Create a new file in this folder, and name it style.css. Link your style.css file to your index.html file.
How?
Place the following code in the
head
of your document<link rel="stylesheet" href="css/style.css">
Open your style.css file.
Create a comment at the top of your CSS file. Write your name, and then put the hex codes for your three colors in the comment (this will help you to reference them later).
How?
Remember, the comment structure for CSS is as follows:
/* Start your comment with a backslash followed by a star. End your comment with a star followed by a backslash. Everything between is your comment! */
Choose one of your colors, preferably one that is highly saturated.
Using CSS, set this to be the color of all your links and h1's. You want to write these styles in your CSS file.
How?
In this example, we are using #990000 as our color. You would use your own color code!
a{ color: #990000; } h1{ color: #990000; }
We are using
a
andh1
as our selectors, because we want to apply the styling to all elements on the page that match those selectors.Add another CSS rule, this time using
h2
as your selector. Set the color of theh2
to one of your other colors.Let's make sure that our index.html has markup that will match our styling. Edit your index.html. At the beginning of the file, directly after your
<body>
tag, create a h1 and make sure that it has your name and "Project Portfolio".Create an h2 under that and make the content "Classwork and Projects for COM372"
Add a paragraph of text under that. Write whatever you want. You can search google for Random Text and get a block of random text.
Your index.html should now have at least the following content.
<!DOCTYPE html> <html> <head> <title>MYNAME Project Portfolio</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <h1>MYNAME's Project Portfolio</h1> <h2>Classwork and Projects for COM372</h2> <p>A paragraph of random text</p> ..... <!-- you shouldn't have dots here, this is just a note to show the page goes on--> </body> </html>
Under the paragraph, create a three new paragraphs. As the content for each one, write your hex codes for your colors. You can add descriptions to your colors
<p>A paragraph of random text</p> <p>Red - #990000</p> <p>Purple - #3D2040</p> <p>Yellow - #FFCF40</p>
Surround each of the three paragraphs with a
<div>
.<div><p>Red - #990000</p></div> <div><p>Purple - #3D2040</p></div> <div><p>Yellow - #FFCF40</p></div>
Create styles for your divs. We want to make them squares and give them background colors. In your
style.css
, write the following styles. Instead of using the sample background color, use one of your colors!div{ width: 200px; height: 200px; background-color: #990000; }
Save your
index.html
and yourstyle.css
, and open yourindex.html
using livepreview. You should see that your divs have changed - they will all have the same background color!We don't want all our divs to have the SAME background color, we want them to have background colors that represent our color scheme. Let's use classes to help us accomplish this.
Edit your index.html. Add classes to each of your divs. The classes should be:
color1
,color2
,color3
.<div class="color1"><p>Red - #990000</p></div> <div class="color2"><p>Purple - #3D2040</p></div> <div class="color3"><p>Yellow - #FFCF40</p></div>
We want to change our selector in CSS to apply to these classes instead of to the element
div
. Edit your CSS rule to have.color1
as the selector instead ofdiv
..color1{ width: 200px; height: 200px; background-color: #990000; }
Save your
index.html
and yourstyle.css
, and open yourindex.html
using livepreview. You should see that your divs have changed - only the first one is styled now!We will need to repeat our styling so that it can be applied to the other divs.
Copy your rule set (from the . that starts the selector all the way through the closing }) and paste it into your CSS twice. You should now have three rulesets, all with the selector
.color1
. Change the second selector to.color2
and the third selector to.color3
. Then, take your two other colors and use them for the background color for the two new rulesets..color1{ width: 200px; height: 200px; background-color: #990000; } .color2{ width: 200px; height: 200px; background-color: #3D2040; } .color3{ width: 200px; height: 200px; background-color: #FFCF40; }
Homework
- Project #3 - Due Monday before class - upload to GitHub and link from your personal portfolio
- Codecademy
- HTML Basics II (Due Monday, September 22, 2014)
- Project: Social Networking Profile (Due Monday, September 22, 2014)