Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Touring the CSS

From: HTML Essential Training

Video: Touring the CSS

In this movie, we'll look at the CSS for the Rock Paper Scissors website, and so the first thing we're going to do is we're going to load up this page here, scissors.html, from the chapter 17 folder in our exercise files. I am just going to open that in the text editor, and you will notice at the top here we have these two link tags: one of them is opening the main.css, and one of the is opening the rps.css. The main.css file is exactly the same as we've been using throughout this course. Let's take a moment and look at it. Open that in our text editor here.

Touring the CSS

In this movie, we'll look at the CSS for the Rock Paper Scissors website, and so the first thing we're going to do is we're going to load up this page here, scissors.html, from the chapter 17 folder in our exercise files. I am just going to open that in the text editor, and you will notice at the top here we have these two link tags: one of them is opening the main.css, and one of the is opening the rps.css. The main.css file is exactly the same as we've been using throughout this course. Let's take a moment and look at it. Open that in our text editor here.

That's main.css from the same folder. And this is really just a set of resets. So the first thing we do is up here at the top, list all of these different selectors for a lot of different elements. And we just set a bunch of margins for them and defaults, and then we set up the body and some more margins for some of these other elements and default font sizes for the headers and default font family for a number of elements. And so it's really just a reset. And a lot of my sites, I'll design them in this way where I will have one reset for the entire site and then I will have other CSS files for other purposes, and it helps to organize everything and to make it easy to manage in the long run.

Now, you will notice here we also have this rps.css, and this is where the specific styling is done for this site. And so I've set a different background-color. I've set line-heights and font-families and colors for text and things, all here at the top. And so if we come back over here to the scissors file, you see there is the background. There's some of the text coloring. These are the things that are specific to this site, and my reset is being overriden here because in the source file, you notice the reset is first, and then is the specific CSS.

So specific CSS is cascading on top of the reset. It's changing those defaults. But it's using them as a basis, and that makes it actually really convenient. Here you notice that I am floating my image right. I am formatting it. And so that's this image here, and it's got this border, and it's got a little bit of padding in there, and that's all set right there. The figure element is actually not used in this incarnation of the site, so we'll just go right past that. Now we have the formatting for the navigation bar, and this was described in the chapter on lists.

In the HTML, it's just this simple unordered list element with a number of list items that have the links in them, and it's all inside of this nav block. And so we format the nav element to have a width all the way across the screen, and so that's this brown bar all the way across the screen there. And there is the background color that makes it that color, and it's hiding everything. And then the unordered list is put in block mode, and list-style: none and it's a width of 600 pixels and it's a margin of 0 and auto, and that's actually how you center something in CSS, and so you see that it's centered here on the page.

And as I change the width of the viewport, that remains centered. And then we set our margin and padding for our list elements and then finally, the bulk of the formatting is done right here in the a element. So this is adescendent selector from top-menu ul li and a. And if we look in our HTML, here is the id="top-menu." There's the ul and the li and the a element. And so each of these a elements have that descendent property, and so they are covered by this descendent selector.

So it sets them into Block mode, and it makes them float left so that they stack next to each other left, left, left, left. And that makes this one stack at the left side of the container. Then this one stacks right up against it to its left side, and these stack this way by having them all have float left like that. Then they're given dimensions. They are given margins. They are given the font family, text-align: center within their little blocks. That way these underlines, which are actually a border-bottom, the text actually centers on top of that.

And that's because we have this text-align: center. The background-color to match the top-menu element and text-decoration: none because that obviously defaults to underlining. We don't want that because we're using the bottom border there to indicate. And we set the color of the text, and the color of the bottom border. You notice that the bottom border color matches again the background color, so it actually disappears. And when we hover over, we have our pseudo selector for hover, and that bottom border color gets changed to the same color as the text, and so that gives it this nice effect.

So that's our nav element. The header element, that's this part right here. We have our h1, which its text properties are getting set up above, and the h2 text properties are getting set up above. The margin-top is just making it flush up here. If we get rid of that margin-top, just delete this, you'll see that we lose that flush up at the top here and we get this brown ugliness. And so we put that in, and that allows it to be flush up with the element above it. It have a descendent selector for the paragraph so that we can format this do not run with these, and then we have our main div.

Our main div is right here, and it goes all the way to right above the footer. That's this one here. And all of this is inside of this main div and right there below the nav element. And the whole point of it is to give it a background color and center it on the page. So we set a width, we set its margin: 0 auto, which we know will center it on the page, and we give it this background-color. And so that is this cream color here that goes all the way down to the footer. Next, we have our article element, and you notice we're also using two selectors here--section.buy and article--and section.buy that's on our Buy page and that's this section right here.

We're just sharing its formatting because it's convenient. We wanted it formatted exactly the same. And so it has a width, it has a margin to the right, and it floats to left, and that allows this aside to float to the right of it. And then we format some of the elements inside it with descendent selectors, the h1, the p, and the mark. We're not using mark, but that's for highlighting. And then we format the aside. The aside floats to the right. We had it floating to left in other parts of this course, and it would make it stack, but when we want to have more than one item to the left of it, having it float to the right allows that to happen.

And so on a lot of these pages, we have different sections to left and we want that to float in that way. Then we have our formatting for inside of it with some descendent selectors-- font-size, margins, fonts-- and then we format our footer. Our footer has this dark gray background, and that's seen down here. And the paragraph inside of it has a lighter color, not quite white, so we see that we have that lighter gray color of the text. And its font size is smaller and its text aligned to the center, and it has some up and down padding.

The first number here is the top and bottom, the second number here is the right and left, and so that's giving it 10 pixels above and below so that the text looks like nice there. Now, we do some formatting for details and summary, and that's not used in this example. And then we have our media formatting, and this is really just margins for that div. And so if we look at one of the pages that has that, here's paper, we'll bring up papers.html and here we have the div media. That's just giving it some top and left margins.

So when we see this on the page, there is a little bit of margin here, and it pulls it away from the side there, because you remember in our reset, it gave it a margin of 0. If we look back up at our reset, it's listed in here audio and video, and they have a margin of 0, padding of 0. So, this helps us to get that away from the side margin there and from what's above it, makes it look nicer there on the page. Then we have some formatting for our forms, just to give them the sans-serif font, and to give a font to the inside of these input and text area elements.

So that's the stuff here. That makes this have a size to it that we can see. Otherwise, on some browsers it will be small; on some browsers it will be large. This makes it consistent. And then down here, we have the CSS for our game, and this is all copied from and it's all explained in the drag-and-drop course, including this transition section down here. So that's the CSS for the Rock Paper Scissors website. The JavaScript for the drag-and-drop game is covered in the HTML 5 Drag and Drop course here on lynda.com.

Show transcript

This video is part of

Image for HTML Essential Training
HTML Essential Training

82 video lessons · 98498 viewers

Bill Weinman
Author

 
Expand all | Collapse all
  1. 5m 24s
    1. Welcome
      56s
    2. Using the exercise files
      1m 37s
    3. What you need to know about this course
      2m 51s
  2. 22m 0s
    1. What is HTML?
      4m 12s
    2. Examining the structure of an HTML document
      7m 50s
    3. Understanding tags and containers
      6m 4s
    4. Exploring content models in HTML5
      2m 23s
    5. Looking at obsolete elements
      1m 31s
  3. 27m 19s
    1. Understanding whitespace and comments
      3m 53s
    2. Displaying text with paragraphs
      3m 37s
    3. Applying style
      8m 5s
    4. Using block and inline tags
      6m 34s
    5. Displaying characters with references
      5m 10s
  4. 16m 36s
    1. Exploring the front matter of HTML
      2m 9s
    2. Applying CSS to your document
      3m 59s
    3. Adding scripting elements
      4m 54s
    4. Using the meta tag
      3m 34s
    5. Optimizing your page for search engines
      2m 0s
  5. 24m 59s
    1. Controlling line breaks and spaces
      2m 46s
    2. Exploring phrase elements
      1m 44s
    3. Using font markup elements
      1m 5s
    4. Highlighting text with mark
      1m 29s
    5. Adding headings
      1m 38s
    6. Using quotations and quote marks
      3m 2s
    7. Exploring preformatted text
      1m 45s
    8. Formatting lists
      2m 28s
    9. Forcing text direction
      3m 49s
    10. Suggesting word-break opportunities
      2m 29s
    11. Annotating East Asian languages
      2m 44s
  6. 29m 15s
    1. Introducing CSS
      55s
    2. Understanding CSS placement
      6m 55s
    3. Exploring CSS syntax
      10m 34s
    4. Understanding CSS units of measure
      3m 3s
    5. Some CSS examples
      7m 48s
  7. 22m 5s
    1. Using images
      4m 13s
    2. Flowing text around an image
      4m 55s
    3. Breaking lines around an image
      3m 3s
    4. Aligning images
      5m 25s
    5. Mapping links in an image
      4m 29s
  8. 22m 28s
    1. Understanding URLs
      2m 41s
    2. Working with hyperlinks
      3m 28s
    3. Using relative URLs
      4m 20s
    4. Specifying a base URL
      2m 19s
    5. Linking within a page
      4m 12s
    6. Using image links
      5m 28s
  9. 17m 2s
    1. Exploring list types
      3m 52s
    2. List elements in depth
      7m 44s
    3. Using text menus with unordered lists
      5m 26s
  10. 15m 30s
    1. Introduction to HTML semantics
      4m 9s
    2. Exploring an example
      4m 56s
    3. Marking up figures and illustrations
      2m 33s
    4. Creating collapsible details
      3m 52s
  11. 11m 18s
    1. Embedding audio
      5m 19s
    2. Embedding video
      5m 59s
  12. 11m 53s
    1. Creating ad-hoc Document Object Model (DOM) data with the data-* attribute
      4m 53s
    2. Displaying relative values with meter
      2m 57s
    3. Creating dynamic progress indicators
      4m 3s
  13. 4m 49s
    1. Overview of HTML5 microdata
      1m 8s
    2. Exploring an example with microdata
      3m 41s
  14. 7m 3s
    1. Understanding outlines
      52s
    2. A demonstration of outlining
      6m 11s
  15. 13m 1s
    1. Table basics
      7m 29s
    2. Exploring the semantic parts of a table
      2m 32s
    3. Grouping columns
      3m 0s
  16. 9m 55s
    1. Frames overview
      54s
    2. Using traditional frames
      4m 26s
    3. Exploring inline frames using iframe
      2m 7s
    4. Simulating frames with CSS
      2m 28s
  17. 53m 7s
    1. Introducing forms
      10m 24s
    2. Using text elements
      10m 12s
    3. Using checkboxes and radio buttons
      2m 37s
    4. Creating selection lists and dropdown lists
      5m 14s
    5. Submit and button elements
      8m 48s
    6. Using an image as a submit button
      2m 15s
    7. Keeping context with the hidden element
      3m 0s
    8. Setting tab order
      2m 7s
    9. Preloading an autocomplete list using the datalist feature
      5m 26s
    10. Displaying results with output
      3m 4s
  18. 19m 47s
    1. Touring a complete site
      2m 14s
    2. Touring the HTML
      8m 44s
    3. Touring the CSS
      8m 49s
  19. 29s
    1. Goodbye
      29s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed HTML Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.