< Return to Video

www.youtube.com/.../watch?v=dC34rfY8Eyk

  • 0:01 - 0:01
    - [Voiceover] We've now learned how
  • 0:01 - 0:03
    to make a pretty complete web page
  • 0:03 - 0:05
    with all sorts of marked
    up texts and images
  • 0:05 - 0:08
    but it's lacking something, style.
  • 0:08 - 0:09
    My web page here looks the same
  • 0:09 - 0:11
    as the webpages you've been making.
  • 0:11 - 0:14
    Black text, white background, same font,
  • 0:14 - 0:16
    everything laid out from top to bottom.
  • 0:16 - 0:17
    You've been on the web and you've seen
  • 0:17 - 0:20
    that web pages can look very
    different from each other.
  • 0:20 - 0:22
    Look around on Khan Academy at
  • 0:22 - 0:25
    all the different colors
    and fonts and sizes.
  • 0:25 - 0:28
    In fact, let's do this now,
    pause this talk through
  • 0:28 - 0:30
    and look at a few different websites.
  • 0:30 - 0:32
    What's different about each of them?
  • 0:32 - 0:35
    What do you like or
    dislike about their style?
  • 0:35 - 0:37
    I'll just wait right here.
  • 0:38 - 0:41
    It's important to see how
    different web pages can be
  • 0:41 - 0:43
    because pretty soon you'll figure out how
  • 0:43 - 0:45
    to make you web pages look different
  • 0:45 - 0:46
    and you wanna do that in a way
  • 0:46 - 0:49
    that makes you happy
    because it represents you
  • 0:49 - 0:51
    but it also makes other users happy too.
  • 0:51 - 0:53
    With this all our web pages we need
  • 0:53 - 0:56
    to learn a whole new language CSS
  • 0:56 - 0:58
    that stands for Cascading Style Sheets
  • 0:58 - 1:00
    and it's a way of defining
    styles that will apply
  • 1:00 - 1:02
    to different parts of our web page.
  • 1:02 - 1:06
    We embed CSS inside of HTML
    but it isn't actually HTML
  • 1:06 - 1:08
    so we have to learn a whole new language
  • 1:08 - 1:11
    and try not to confuse HTML with CSS.
  • 1:11 - 1:13
    We'll see how we can use
    CSS to style all sorts
  • 1:13 - 1:15
    of aspects of our web page like the font,
  • 1:15 - 1:17
    sizes and layouts but we'll start
  • 1:17 - 1:20
    with something that's pretty fun.
  • 1:20 - 1:22
    Color, how about we change some headings
  • 1:22 - 1:25
    on our web page to a nice grassy green.
  • 1:25 - 1:28
    To start, we need to add a style tag
  • 1:28 - 1:30
    to the head of our page.
  • 1:32 - 1:34
    When the browser sees that, it will think,
  • 1:34 - 1:37
    "Okay, everything inside here is CSS.
  • 1:37 - 1:40
    "I'll use my CSS parser to understand it
  • 1:40 - 1:43
    "instead of my HTML parser."
  • 1:43 - 1:48
    Inside here, we'll add a CSS style rule.
  • 1:48 - 1:50
    A style rule has a selector which tells
  • 1:50 - 1:52
    a browser what part of a web page
  • 1:52 - 1:54
    to style and declarations, which tell
  • 1:54 - 1:57
    the browser how to style their part.
  • 1:57 - 2:00
    If we want to style all
    the h2s on our page,
  • 2:00 - 2:05
    we'll type the selector h2 and
    then we'll do curly braces.
  • 2:06 - 2:08
    Make sure they're curly, not square
  • 2:08 - 2:10
    or round those won't work.
  • 2:10 - 2:13
    Inside, we'll put our declarations
  • 2:13 - 2:15
    which have properties and values.
  • 2:15 - 2:19
    To change the text color,
    we use the color property
  • 2:19 - 2:23
    then we put a colon and now we
    need to come up with a value.
  • 2:23 - 2:26
    We need to tell the browser
    what color we're interested in.
  • 2:26 - 2:28
    Well we could just
    write green and it would
  • 2:30 - 2:32
    understand it because
    green's a common color
  • 2:32 - 2:34
    but that's not the green I wanted.
  • 2:34 - 2:36
    I want a grassy green.
  • 2:36 - 2:40
    If I write grassy green, uh oh.
  • 2:40 - 2:42
    Now the browser gets confused and makes
  • 2:42 - 2:44
    the headings black again because
  • 2:44 - 2:46
    it's never heard of grassy green.
  • 2:46 - 2:48
    If we want to be able to
    specify any color at all,
  • 2:48 - 2:52
    then we need to use something
    called the RGB Spectrum
  • 2:52 - 2:54
    which maybe you've heard
    about in art class.
  • 2:54 - 2:56
    You don't need to be
    an expert in it though
  • 2:56 - 2:59
    because we have an RGB
    color picker for you here.
  • 2:59 - 3:04
    To use it, just replace
    this with RGB parentheses
  • 3:04 - 3:06
    and a color picker will pop up.
  • 3:06 - 3:08
    You can move your mouse inside of it
  • 3:08 - 3:11
    and pick a color and you
    can see the color update
  • 3:11 - 3:15
    in real-time and when you're happy click.
  • 3:15 - 3:17
    Now do you notice how
    there were three numbers
  • 3:17 - 3:20
    that it changed in our RGB parentheses?
  • 3:20 - 3:23
    That's the red, green and blue
  • 3:23 - 3:26
    components that make up that color.
  • 3:27 - 3:30
    Okay, the neat thing
    about this CSS selector h2
  • 3:30 - 3:34
    that we used is that selects
    all the h2s on the page
  • 3:34 - 3:36
    so we can change multiple headlines
  • 3:36 - 3:39
    because we want all of
    those h2s to be green.
  • 3:39 - 3:43
    It's consistent for all those
    h2s it finds on the page.
  • 3:43 - 3:45
    If you keep going with CSS, you can learn
  • 3:45 - 3:48
    about many other ways of
    selecting parts of a page
  • 3:48 - 3:50
    like if you wanted one of those h2s.
  • 3:50 - 3:54
    You can go pretty far with
    these tag based selectors.
  • 3:55 - 3:56
    Let's add another CSS style rule.
  • 3:56 - 3:59
    This time to make the
    background a sky blue.
  • 3:59 - 4:02
    How would we color the
    background on a page?
  • 4:02 - 4:06
    Well, which tag
    encompasses the whole page,
  • 4:06 - 4:09
    it's not the h1s, it's not the p,
  • 4:09 - 4:12
    it's not the image, it's the body tag.
  • 4:12 - 4:14
    Remember, everything visible is always
  • 4:14 - 4:16
    inside that body tag.
  • 4:16 - 4:19
    If we want to style the entire the page,
  • 4:19 - 4:22
    we need to use a selector
    to select that tag.
  • 4:23 - 4:25
    So we'll write body.
  • 4:27 - 4:30
    Now, instead of color,
    we'll write background
  • 4:30 - 4:32
    color, colon
  • 4:33 - 4:36
    and then rgb parentheses.
  • 4:36 - 4:40
    We get our color gripper
    and I'll pop it up
  • 4:40 - 4:42
    and pick a blue that makes me think
  • 4:42 - 4:46
    of frolicking bunnies and cumulus clouds.
  • 4:46 - 4:49
    Ta da, look at my stylish page.
  • 4:49 - 4:52
    There are hundreds more CSS properties
  • 4:52 - 4:54
    besides color and background color
  • 4:54 - 4:57
    but those ones are fun
    to get started with.
  • 4:57 - 4:59
    In fact, after I'm done
    talking, play around
  • 4:59 - 5:02
    with the colors I picked
    and customize this page
  • 5:02 - 5:05
    to be more your style than mine, okay?
  • 5:05 - 5:07
    Go.
Title:
Video Language:
English
Duration:
05:09
  • I wish someone would have told me what was wrong with my subtitles instead of editing them. I worked hard to make them meet the suggested guidelines for reading speed, etc., and now there are what I would call timing errors and places where the reading speed reaches >26 cps, when it was suggested to keep it <22.

    What was wrong with my subtitiles, and why are these better?

  • Hi,
    On the English sub-titles, I would suggest to update the text at 4:11 ("If the body tag, remember..."), by " it's the body tag...". By translating in french, I found that it sounds better that way.

  • The latest English revision also introduces inaccuracies. Should I try to correct them?

  • Still hoping to hear from the community about my subtitles. I've noticed that during that previous edit, some of my words were changed also, so it has introduced actual errors as well. I don't think it would be right to revert someone else's work, but I feel there were fewer mistakes in the previous revision.

English subtitles

Revisions