Latest Lists

How do you get an unordered list to line up in xhtml when using an external style sheet?

Public Comments

  1. Check out tutorial sites below.
  2. If I correctly interpret your question to mean "line up horizontally"... save this as horizList.css - - - - ul.linedUp { /* optional to make it only thing on "line" */ clear: both; /* no bullets - no vertical "stacking" */ list-style: none outside; } ul.linedUp li { /* optional border to show where the li is */ border: .125em solid blue; /* these do the horizontal "stacking" */ display: block; float: left; /* options to make it "prettier" */ margin: .25em; padding: .25em; text-align: center; width: 8em; } save this as horizList.html - - - - <html> <head> <link rel = "stylesheet" href = "horizList.css" type = "text/css" /> </head> <body> <ul class = "linedUp"> <li>list item 0</li> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> </ul> </body> </html> Note that I couldn't properly declare an XHTML doctype, since Y!A would truncate the URL attributes. The correct specification would be like the following without the blanks that are embedded in the URLs: <?xml version = "1.0" encoding = "UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// www.w3.org/ TR/xhtml1/ DTD/ xhtml1 - strict.dtd"> <html lang="en" xml:lang="en" xmlns="http:// www.w3.org/ 1999/ xhtml">
Powered by Yahoo! Answers