Sponsored Ad

Thursday, December 10, 2009

How to Create a Lists in HTML

Ordered lists and unordered lists work the same way, except that the former is used for non-sequential lists with elements of the overall list, preceded by bullets and the second is for sequential lists, which are typically represented by additional numbers.

The UL mark is used to define ordered lists without the ol tag is used to define ordered lists. Within the lists, the li tag is used to define each element of the list.

Change your code to the following:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3.  
  4. <html>
  5.  
  6. <head>
  7.     <title>My first web page</title>
  8. </head>
  9.  
  10. <body>
  11.     <h1>My first web page</h1>
  12.  
  13.     <h2>What this is</h2>
  14.     <p>A simple page put together using HTML</p>
  15.  
  16.     <h2>Why this is</h2>
  17.     <ul>
  18.         <li>To learn HTML</li>
  19.         <li>To show off</li>
  20.         <li>Because I've fallen in love with my computer and want to give her some HTML loving.</li>
  21.     </ul>
  22.  
  23. </body>
  24.  
  25. </html>

If you look at this in your browser, you will see a bulleted list. Just change the ol UL labels and note that the list will be numbered.

Lists can also be included in lists to form a structured hierarchy of items.

Replace the above list code with the following:

  1.        <ul>
  2.     <li>To learn HTML</li>
  3.     <li>
  4.         To show off
  5.         <ol>
  6.             <li>To my boss</li>
  7.             <li>To my friends</li>
  8.             <li>To my cat</li>
  9.             <li>To the little talking duck in my brain</li>
  10.         </ol>
  11.     </li>
  12.     <li>Because I've fallen in love with my computer and want to give her some HTML loving.</li>
  13. </ul>

0 comments:

Post a Comment

Sponsored Ad



More Related Articles

Website Update

Recent Posts

Followers