You know the primary colors are red, blue, and yellow:

Fill in the blanks with red, blue, and yellow:

red + = purple
blue + = green
yellow + = orange

But the primary colors for computer and TV screens are different. They are red, green, and blue.

A screen is made of pixels. You may think a pixel is a tiny square lightbulb. It's actually 3 really tiny rectangle-shaped lightbulbs, called subpixels.

In each pixel, there is one red, one green, and one blue subpixel.

Fill in the blanks with red, green, and blue. Use the process of elimination!

red + = purple
blue + = turquoise/cyan
green + = yellow

Each pixel has an RGB code that says what color it should make.

R G B

To make the color purple, a pixel needs its red and blue subpixels turned on, and its green subpixel turned off:

R … B

The RGB code for a purple pixel is:

255, 0, 255

What does RGB stand for?

The 3 numbers in a purple pixel's RGB code show:

A yellow pixel has an RGB code of:

255, 255, 0

The first number of 255 means…

The third number of 0 means…

An orange pixel has an RGB code of:

255, 170, 0

The second number of 170 means…

Fill in the blanks with 255, 170, or 0 to complete all the RGB codes:

white 255 255
black 0
green 0 0
blue 255
teal 0
yellow 255 0
orange 170 0
grey 170

We usually use decimal numbers. But programmers often use hexadecimal numbers — or hex — instead.

The dec in decimal means ten. The hex in hexadecimal in hexagon both mean:

Since hexadecimal contains hex plus dec, hexadecimal probably means:

The decimal system is also called base ten. So hex is probably also called:

In the decimal system there are ten digits.
In the hexadecimal system there are sixteen digits:

Decimal: 0 1 2 3 4 5 6 7 8 9
Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F

Hex uses the letters A to F for the numbers 10 to 15.

This lets you write bigger numbers in fewer spaces: 10 in decimal and A in hex are both the same number, but 10 is two spaces long, and A is only one.

Let's count up in decimal and hex:

Dec Hex A 40 28
1 1 11 29
2 12 2A
3 13 43
4 14 44
5 F 45
6 10 46
7 11 2F
8 12 30
9 19 31

30 equals 3 times the number of digits in the system you are using.

The decimal system has digits,
so 30 in decimal = (3 × ).

The hex system has digits,
so 30 in hex = (3 × ),
which works out to the number .

D in hex is the number .
(Hint: Look at the chart on the last page.)

3D = 30 + D. Converting 30 and D into numbers,
3D = +

So, 3D equals the number .

Which one of the following is NOT true?

Here are some RGB codes in decimal and hex:

decimal hex
red 255, 0, 0 FF0000
white 255, 255, 255 FFFFFF
dark green 0, 170, 0 00AA00

A hex RGB code is actually 3 numbers. FFAA00 for the color orange is actually FF for red, AA for green, and 00 for blue.

Fill in the blanks using FF, AA, and 00:

  • 0 in decimal is the same as in hex.
  • 255 in decimal is the same as in hex.
  • 170 in decimal is the same as in hex.

Computer programmers may like to write RGB codes in hex instead of decimal because…

Complete all the hex codes using FF, AA, or 00:

black
green 00
blue FF
teal 00
yellow FF 00
orange AA 00
grey AA

Knowing how hex works makes it easier to find the perfect color for your website or app.

Just remember: When you see ABCDEF, you're seeing three numbers: AB for red, CD for green, and EF for blue.

Let's try adjusting some colors in hex:

000000 + 1 level of red = 010000
FF00AA + 1 level of = FF01AA
+ 1 level of blue = FFFF01
DEFFC8 – 1 level of green =

Fill in the blanks with > or < to show which hex code is bigger.

  • Remember letters are bigger than numbers
  • The code that starts with the bigger digit is the bigger code
00 < FF
00 01
D3 A3
22 D2
0F 10
1A 19

Rank the brightness of red, green, and blue in each hex code. 1 is least, 2 is in the middle, 3 is most.

Red Green Blue
332211 3 2 1
FFAA00
AA99BB
80A00D
2B5A77

RGB codes are case-insensitive: the computer treats them the same if they're UPPERCASE or lowercase.

One neat thing about knowing hex is you can make colors from words, using the letters A through F!

You can also cheat and use some numbers in place of letters, like 5 for S.

Fill in the blanks to translate English words into RGB codes and figure out what colors they make.

The missing colors are purple, red, and yellow.

decode dec0de pastel pink
0ff1ce blue-green
old dad turquoise/cyan
coffee sea green
doodle
ba11e7
fedora fed02a
Bieber pale blue-green

What other words can you turn into colors?

This paragraph has been styled to look different from the other paragraphs in this book. The code for styling is called CSS. The CSS for this paragraph is below.

Complete the CSS for the paragraph above.

Some hints:

  • Try reading the code like English.
  • Remember what you know about RGB codes! This is a book, so the only colors are black and white.
  • CSS is very picky about punctuation.
  • #000000;
  • #FFFFFF;
  • italic;
  • center;
  • 12px;
  • 5px dotted #FFFFFF;






A property is something you have. A value is an amount, a measurement, or a setting — like how you can set your phone's ringtone.

Fill in the blanks with property or value:

This house is worth a million dollars!
This background is red!

House and background are both a .
A million dollars and red are both a .

font-style:italic;

font-style is a , and
italic is a .

If I announce This property has that value! — like My favorite food is pizza! I am making a…

When you pick a CSS property and give it a value, you make a declaration, like this:

background-color:#FF0000;

This declaration has 3 punctuation marks:

: colon
; semicolon
# pound, or hash

Fill in the blanks with the right punctuation mark:

  • Every CSS property has after it.
  • Every CSS declaration ends with .
  • Every RGB code begins with .

Computers are very picky about punctuation in CSS. If the punctuation is wrong, the CSS won't work.

Give each declaration the correct punctuation:

background-color 000000
color FFFFFF
font-style italic
text-align center
font-size 12px
border 5px dotted FFFFFF

There are over 500 CSS properties.

This means each image, button, or piece of text you see on a webpage has 500 different settings you can change to make it look different. That's a lot!

How do you think most web designers memorize the CSS properties?

The world's best programmers use Google…

If a professional programmer has to use Google…

Complete the CSS declarations.

Remember to use colons :, semicolons ;, and hashes or pounds #.

  • url(stars.jpg)
  • 400px
  • FF9900
  • rotate(30deg)
  • hidden
  • bold






px stands for:

deg stands for:

Each CSS declaration needs a selector. It tells your computer which part of a webpage it should select to use with that declaration. For example:

p, code, img{
  width:400px;
  height:200px;
}

This tells your computer that it should select something and make it 400 pixels wide and 200 pixels high.

Which part do you think is the selector?

What do you think this rule is selecting? (What would be the most useful?)

A selector and its declarations are called a CSS rule.

Why is it called a rule?

A rule can be written on one line, or many lines. But the punctuation is always the same.

Which of these do you think is most likely to make a rule for every abbreviation and definition on a webpage?

What's wrong with this CSS rule?

p, code color:#F00; text-align:center;

What's wrong with this CSS rule?

q{ background-color:#CCC color:#0F0; }

What do you think q will select?

This selects every quote and every piece of code:

q, code

This selects every piece of code inside a quote:

q code

So, p img (with no comma) will select:

…and p, img will select:

Which one of the following do you think is true?

  • form button
  • form p button
  • form, p, button
  • form, button

Fill in the selectors for…

Every button that's in a form.

Every button in every paragraph in every form.

Every button, every paragraph, and every form.

Every button and every form.

All of a website's CSS is usually kept in a stylesheet:

1 |  p, code{
2 |    color:#000000;
3 |    font-size:18px;
4 |  }
5 |  p{
6 |    color:#FF0000;
7 |  }
8 |  code{
9 |    color:#0000FF;
10|  }

It's a sheet of style rules.

This CSS changes the color for paragraphs 2 times. Which color do you think the computer will use?

The font of every code snippet will be:

The C in CSS stands for cascading, like a waterfall. This means three things:

  1. If a website has two stylesheets, it uses both of them.
  2. If a website has two CSS rules for paragraphs, it uses both rules…
  3. but if both rules have a color, the website will ignore the first color and use the second one.
1 |  p{
2 |    background-color:#000000;
3 |    color:#FFFF00;
4 |  }
5 |  code, p{
6 |    background-color:#00FF00;
7 |  }
8 |  code{
9 |    background-color:#000000;
10|    background-color:#0000FF;
11|  }

Fill in the blanks with the right 2 colors:

  • red
  • blue
  • yellow
  • green

This CSS means paragraphs will have backgrounds, and code snippets will have backgrounds.

<h1>Introducing HTML</h1>

<p>If you look at the code for any webpage on the Internet, the first thing you see is <dfn>HTML</dfn>. You <em>always</em> start coding a webpage by writing HTML.</p>

<p>HTML is a way of grouping words together. It lets you say to your computer, <q>Hey, <em>this</em> group of words has <em>that</em> job.</q> </p>

What seems to be true about < > and </ >?

  • headline
  • paragraph
  • quote
  • definition
  • emphasized
  • <p> says, This is a .
  • <em> says, This is .
  • <dfn> says, This is a .
  • <q> says, This is a .
  • The h in <h1> says, This is a .

< > and </ > are called tags because…

A webpage can have as many tags as you want. They are (almost) always used to group words together.

A group of words beginning with an open tag and ending with a close tag, <em>like this one</em>, is called a(n)…

HTML has simple rules:

  1. Elements need an open tag and a close tag.
  2. Elements have to nest.

What do you think nest means in HTML?

<em><p>Two</em> things are wrong with this piece of HTML.</p><p>What are they?

There are about 100 HTML elements. But you use only about 15 of them for most things.

Use the word bank to match common elements to their definitions.
Include the correct punctuation!

  • <h1>
  • <p>
  • <blockquote>
  • <em>
  • <q>
  • <ol>
  • <strong>
  • <ul>
  • <h2>
  • <li>
Headline for the most important content on the page
Headline for the second-most important content on the page
Paragraph
Quote
Long quote
Emphasized
Really emphasized
Unordered list (bullet points)
Ordered list (1 2 3… A B C…)
Item in a list (a list item)

The inventors of HTML liked abbreviations.

They could have invented a <paragraph> tag. Instead, they invented a <p> tag.

But if you don't know HTML, <paragraph> is much easier to understand than <p>.

So, why did the inventors choose <p> instead of <paragraph>?

Things you write really fast can be hard to read. Things that are easy to read can take a long time to write.

Whenever you're making a coding language, you want your language to balance being easy to write and easy to read.

Think back to CSS.

On a webpage, to change the background colors for all paragraphs and quotes to red, and all headlines to blue, you would create a stylesheet like this:

1 |  p, q{
2 |    background-color:#FF0000;
3 |  }
4 |  h1{
5 |    background-color:#0000FF;
6 |  }

Quick review: What do you call the part before the {curly braces} h1 or p, q in this case?

Which one of the following seems to be true?

You usually create two files to make one webpage:

  1. An HTML document, maybe named index.html
  2. A CSS stylesheet, maybe named styles.css

These files can be named anything you want, but should end with .html and .css.

A stylesheet can be long or short. Your webpage will work fine with no stylesheet at all (but it may not look very good).

You can put CSS and your HTML in one file instead of two, but this is considered bad. Why?

Every webpage on the Internet begins the same way:

1 |  <!DOCTYPE html>
2 |  <html>
3 |    <head>
4 |      <title>My Webpage</title>
5 |    </head>
6 |    <body>
7 |      <h1>Hello, world!</h1>
8 |    </body>
9 |  </html>

You should always…

  • …begin with <!DOCTYPE html>
  • …have exactly one html element
  • …have exactly one head and body inside the html
  • …have exactly one title inside the head

What might head, title, and body do?

  • Where you put content. What you see when you look at a webpage.
  • A label you see in your browser history, your bookmarks, and listed on Google — but not on the webpage itself.
  • Where you put metadata — information that humans don't usually need to read, or that shouldn't show up on the webpage itself.

What is this?

A sample of a book. The complete book will be printed on paper, which is why it's without a computer.

Why?

Because other learn-to-code books are:

  • Boring. I thought a more interactive one would be fun.
  • Expensive. You can code a website from scratch and publish it, all for free from a library computer. Why change that?
  • Long. The only people who want to read 300 pages about Javascript already know Javascript.

Who's this for?

People who say, I'm just not a computer person.

Who are you?

Robert, aka Robin. Source code on Github.

Kickstarter: Support this book and learn more!