Select Page

Lists

So, we just listed all of those really cool things we want to do above! How would we actually write a list of things we like on our about me pages? How about a list?

Unordered Lists:

Unordered Lists are bulleted lists. This is where we will introduce the concept of an attribute (don’t worry, we’ll go into a lot more detail later). Attributes let us futher customize our code!

Take a look at this default unordered list:

<!doctype html>
<html>
  <head>
  </head>
  <body>
    <h1> Welcome to my site! </h1>
    <hr />
     <ul>
       <li>I really like to write code</li>
       <li>I also really like to take pictures of bugs</li>
       <li>It would be super neat if I could make a photo blog for all of my bug pictures !</li>
       <li>Maybe once we learn how to include images into our site we can start posting bug pictures?</li>
     </ul>
  </body>
</html>

By using attributes, we can start changing things up in our lists (we’ll go into how attributes work in detail after this section!):

Check out how these attributes change the list:

<!doctype html>
<html>
  <head>
  </head>
  <body>
    <h1> Welcome to my site! </h1>
    <hr />
     <ul>
       <li type='square'>I really like to write code</li>
       <li type='square'>Does that make me a square?</li>
       <li type='square'>Some people do call me a block head...</li>
       <li type='square'>Maybe they're just not seeing me at the right ANGLE?</li>
     </ul>
  </body>
</html>

We can do what we did above, but, that’s a lot of work to write type='square' on each single list item <li>. What we can do instead, is write it on top, at the unordered list <ul> level, and the type='square' will fall through down to the list items. Check out how much easier that was to write:

&lt;!doctype html&gt;
&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt; Welcome to my site! &lt;/h1&gt;
    &lt;hr /&gt;
     &lt;ul type='square'&gt;
       &lt;li&gt;I really like to write code&lt;/li&gt;
       &lt;li&gt;Does that make me a square?&lt;/li&gt;
       &lt;li&gt;Some people do call me a block head...&lt;/li&gt;
       &lt;li&gt;Maybe they're just not seeing me at the right ANGLE?&lt;/li&gt;
     &lt;/ul&gt;
  &lt;/body&gt;
&lt;/html&gt;

The types we can use for unordered lists are:

&lt;ul type='square'&gt;&lt;/ul&gt;  &lt;!-- blocks --&gt;
&lt;ul type='disc'&gt;&lt;/ul&gt;  &lt;!-- bullets --&gt;
&lt;ul type='circle'&gt;&lt;/ul&gt; &lt;!-- empty circles --&gt;

Ordered Lists:

Ordered lists are just like unordered lists, but, well, they’re ordered! They’re numbered/lettered in some way that gives order to the list! EXCITING! They work in the exact same way of unordered lists, but instead of using the unordered list <ul> we use the ordered list <ol>. Check it out:

&lt;!doctype html&gt;
&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt; Welcome to my site for counting!! &lt;/h1&gt;
    &lt;hr /&gt;
     &lt;ol&gt;
       &lt;li&gt; I love counting! &lt;/li&gt;
       &lt;li&gt; Math is super neat!&lt;/li&gt;
       &lt;li&gt; Did you know that accountants count things for a living!? &lt;/li&gt;
       &lt;li&gt; Actuarily, we should account for all mathematically focused jobs!&lt;/li&gt;
     &lt;/ol&gt;
  &lt;/body&gt;
&lt;/html&gt;

Just like unordered lists, we can use attributes to change how we’re listing things:

&lt;!doctype html&gt;
&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt; Welcome to my site for counting!! &lt;/h1&gt;
    &lt;hr /&gt;
     &lt;ol type='I'&gt;
       &lt;li&gt; love counting! &lt;/li&gt;
       &lt;li&gt; Roman numerals are super weird!&lt;/li&gt;
       &lt;li&gt; Did you know romans didn't have a number for zero?!? &lt;/li&gt;
       &lt;li&gt; In fact, the Greeks didn't either!! Weird huh??&lt;/li&gt;
     &lt;/ol&gt;
  &lt;/body&gt;
&lt;/html&gt;

Here are the types of ordered lists we can use!

&lt;ol type='1'&gt;&lt;/ol&gt; Numbers!
&lt;ol type='a'&gt;&lt;/ol&gt; Lowercase letters!
&lt;ol type='A'&gt;&lt;/ol&gt; Uppercase letters!
&lt;ol type='i'&gt;&lt;/ol&gt; Lowercase roman numerals!
&lt;ol type='I'&gt;&lt;/ol&gt; Uppercase roman numerals!

4084