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

List elements in depth

From: HTML Essential Training

Video: List elements in depth

The list elements are really very flexible. Let's take a look at some details on how these work. We're going to make a working copy of lists.html. I am going to rename this as lists-working. I am going to open this in my text editor here, and I am going to go ahead and open it also in the browser. So here we have a simple document, with the three different types of HTML lists in it. The first thing I want to show you is that it is possible to nest these lists.

List elements in depth

The list elements are really very flexible. Let's take a look at some details on how these work. We're going to make a working copy of lists.html. I am going to rename this as lists-working. I am going to open this in my text editor here, and I am going to go ahead and open it also in the browser. So here we have a simple document, with the three different types of HTML lists in it. The first thing I want to show you is that it is possible to nest these lists.

So if I take this whole ordered list and I just make a copy of it, and I'll make another copy of it, right there in the middle of the existing list-- of course I'm just indenting them so that it's clear; that doesn't affect how they are rendered-- and if I go ahead and reload this, you see we now have three different lists and they are nested within each other. And you notice that they each start over at 1. So if I wanted to, I could come over here and I could put start="5" on this second ol, and when I reload over here, you'll see it's 5, 6, and 7.

The inner one is still starting at 1, 2, and 3. If I wanted to, there I could say type="i" and start="7" and save that and reload, and you see now we have 7, 8, 9 in roman numerals for that inner one. So there is really a lot of flexibility in how this works with the nested lists. And if I nest the unordered lists, see, we get this other behavior here, and I reload this, you'll see that we have the discs and the circles and the squares for the different levels of nested unordered lists.

So I am going to go ahead and remove that nesting, and I'm going to include now our CSS reset so you can see another interesting aspect of these. So I am just going to expand this so you can see the whole line there. I have included our CSS style sheet that does resets, and when I reload this, you see that these are still formatted very much like they were before. And that's because if we look at our CSS reset file here, you notice I really don't do much to the lists.

The only thing in here is for the ordered list, unordered list, and the li elements. I've got margin, padding, border, font-size--those things reset. I am not doing anything actually specifically about the lists; instead, I am going to come in here and I am going to add a little reset here. Let's say style. And normally when I use my resets in a website, I'll have something like this in here. I am going to say dl, dt, dd, ol, ul, li, and so that's all of the list-related elements.

I am going to come in here, and I am going to set the margin and the padding, and the border, all to 0. When I save this and I reload in the browser, now, that's interesting. Of course we expected them all to have no margin, no border, and no padding. What might have been unexpected is that all of the bullets and those kinds of things have disappeared. Otherwise, it's a great place to start, because it normalizes the display across the platform, so that's what a reset is for. But with the bullets and the numbering disappeared, that's not right.

What's actually happened is they're still there; they're just outside of the margin. I am going to show you why here. I am going to go ahead and I am going to put a div around all of these list elements, and I am just going to call it outer. And I am going to come up here into our style sheet. I am going to say outer, and so that's the id selector, say margin-left: 50px, and I am going to give it a border. Put this on a separate line; do this right. And now when I reload over here, we'll have them inside this div, and it has this indent, and you'll notice that outside of the margin we've got our numbers and our bullets.

Now, that may seem weird, but that is the default on all the browsers that I know of. Of course there is no guarantee that that's the default on all of them, so we can't specify it. So we can come out here and we're going to say for ol and ul elements, list-style-position: inside. Now, there's two possible values here-- outside and inside--and outside is the default. And when I change it to inside, now all of those numbers and bullets are inside of the margin.

And when I scroll back down here--I am just going to take out this div. We don't need it anymore. And I can take out the styling for the div. Save this and reload. Now this might be more of what we expect; we have the numbers and we have the bullets displayed, even with our margins set to 0. Now, you don't have to do this. You can set that list-style position to outside, and if I just change this to outside and reload, you'll see there is our default. But if you want to have those within the margins of whatever containers you're putting this in, you might want to set it to inside.

So, just for display purposes and to make this line up with things, we're going to go ahead and put a margin-left. I am going to say 1ex, which is the default that I have for these other elements here. And so it lines up nicely with our header. And now let's take a look at some of the possibilities here. So I am going to go ahead and I am going to put some class names in here. I am going to say class for the ordered list-- I am just going to call it ordered-- and a class for the unordered list as unordered. And come back up here into our style sheet and I am going to say for the ordered list, say list-style-type, I am going to say lower-alpha.

Let's make this a little bit wider here so it all fits. And we can actually move this over a little bit. And this is just for our purposes of being able to experiment here. So I save that and reload it, and now we have lowercase alpha and I can say upper-alpha. Then I'll have uppercase alpha. I can say lower-roman and we have the lowercase roman numerals. I can say upper-roman, and we have the uppercase roman numerals. Now let's look at some of these other options. I can say katakana. We get Japanese.

There is really a lot of them available. There's also katakana- iroha. Save this and reload. Different type of katakana. There's hiragana and also hiragana-iroha. There's Armenian. Reload that. You can do decimal with a leading 0, like that (decimal-leading-zero). There's georgian. There's really a lot of them. Or if we like, we can even use an image. We can say list-style-image. I am going to do this for the unordered list.

These same things work for both the ordered and the unordered list, but images are more common for the unordered list because they'll replace the bullets. So that's url(images/scissors-small.png. And that's an image that we have in our exercise files, and you see it's a small thumbnail size of my little scissors picture. So we again have 1, 2, 3 for the ordered list and our unordered list now has these images.

That's a great feature if you want to create your own types of bullets. So you can see that there are many, many options available. Of course you can and likely will apply other CSS properties to your list elements. Formatting your list with CSS is a very powerful way of presenting lists in your documents.

Show transcript

This video is part of

Image for HTML Essential Training
HTML Essential Training

82 video lessons · 101658 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.