Computers and Technology
CSS Lesson 4 Lists
Lists are an important part of CSS, they are used to primarily make navbars. I’ll cover some basics with you and how to set up your list. In my NEXT tutorial, I’ll show you how to make VERTICAL navbars. I know, I know, you’re asking, “Why are you splitting it up?” Well, mostly because I’ll have to cover vertical and horizontal navigation separately. There are tips and tricks to both, and although some apply to both, many do not. I’m starting out with lists all alone because it’s easier that way. When you need to review an item in CSS, you can switch between the different lessons and it won’t be all jumbled up. I’ve found that numerous tutorials online do not explain this area thoroughly enough so I hope it will help you out.
![]()
Lists are important in PHP, and especially to navbars so I plan to spend some time discussing the HTML as well. There are two basic types of lists: an ordered list that starts with the tag <ol> and an unordered list <ul>. The idea is that you enclose a list in these tags and then write out each item with the tags <li> surrounding them. Here is what it should look like:
<ul>
<li>first item</li>
<li>second item</li>
</ul>
- first item
- second item
Substitute <ol> for <ul> and you’ll get a numbered list:
- first item
- second item
There are also definition lists but you won’t need to know these to create navbars, at least not with me, but here is how they work. You start out with a <dl> tag to tell the browser you’re making a definition list. Then you list a definition term <dt> followed by the defintion description <dd> like this:
<dl>
<dt>cow</dt>
<dd>an animal</dd>
<dt>dog</dt>
<dd>another animal</dd>
</dl>
- cow
- an animal
- dog
- another animal
One more thing, you can embed multiple lists by starting another list inside a list. Let me show you:
<ul>
<li>first item
<ul>
<li>item a</li>
<li>item b</li>
</ul>
</li>
<li>second item</li>
</ul>
- first item
- item a
- item b
- second item
And that’s it for the HTML part. Simple, huh? Well remember it. All you need to really remember is how to start an unordered list with <ul> and that each item in the list has to be enclosed within the <li> tag.
The above was just to make sure you know how to do all of that basic stuff. Let’s move onto the basic CSS when it comes to lists. Now, you may wonder, what basics? Well, to create a navbar, you need to know everything from the previous lessons, especially all that stuff about borders and padding. There are SOME properties only inherent to lists, and that’s what I’ll deal with here.
Let’s start with the unordered list. You see those bullet points on the left of the item? Let’s change them to something else:
ul.circle {list-style-type: circle}
- circle
ul.square {list-style-type: square}
- square
ul.disc {list-style-type: disc}
- disc
ul.none {list-style-type: none}
- none
For the ordered list, you can use the same as above except in the CSS you’d change “ul” to “ol”. You can also use the following:
ol.armenian {list-style-type: armenian}
- armenian
ol.decimal {list-style-type: decimal}
- decimal
ol.leadingzero {list-style-type: decimal-leading-zero}
- decimal-leading-zero
ol.georgian {list-style-type: georgian}
- georgian
ol.loweralpha {list-style-type: lower-alpha}
- lower-alpha
ol.upperalpha {list-style-type: upper-alpha}
- upper-alpha
ol.lowergreek {list-style-type: lower-greek}
- lower-greek
ol.lowerlatin {list-style-type: lower-latin}
- lower-latin
ol.upperlatin {list-style-type: upper-latin}
- upper-latin
ol.lowerroman {list-style-type: lower-roman}
- lower-roman
ol.upperroman {list-style-type: upper-roman}
- upper-roman
List-style-position is the next property, its values are “inside” and “outside”. The default is set to “outside” and it determines the indent of the list. If you want the indent to be counted from the beginning of the text, it’s “outside”. If you want the text to start from the bulletpoint, use inside.
<ul style=”list-style-position: inside”>
- text
<ul style=”list-style-position: outside”>
- text
Let’s say you want an image to replace the bulletpoint, you set up a special “arrow” or whatever to replace it. You can do that using list-style-image and the following formula:
ul { list-style-image: url(‘image.png’) }
Replace image.png with the right address. Unfortunately, this style is not supported by all browsers so I’ll use a little trick mentioned at W3Schools:
ul
{
list-style-type:none;
padding:0px;
margin:0px;
}
li
{
background-image:url(‘arrow.png’);
background-repeat:no-repeat;
background-position:0px 5px;
padding-left:14px;
}
All you do there is remove the lis-style-type and added a background image to the <li> tag that will be used as the bullet point. Finally, let’s look at the shorthand:
ul {
list-style: none outside url(arrow.png);
}
The order of properties is: type, position, image.
That’s it for lists! Yeah, nothing exciting, I know but it’s essential to know these things before moving on to navigation bars.
Here’s what we’ll be dealing with in my next tutorial by putting all the previous tutorial information together:
Click on the picture and it’ll take you to an example vertical navbar
Related posts:
No comments yet.
When your project fails…
January 31, 2010 - 10:04
Tags: blog, php, web design, webpage
Posted in General Articles | 8 comments
Mobile Websites (tips)
January 11, 2010 - 18:28
Tags: css, Design, HTML/CSS, mobile, php, webpage, website
Posted in HTML/CSS, PHP and Scripting, Tutorials | 4 comments
I’ve recently started working on some mobile websites. You’ll notice that davepcguy.com has its own mobile alternative as do some other sites. Mobile devices are growing in number and gone are those days when internet was viewed only on the computer screen. WAP is not even used either so that old school coding is gone [...]
Only A Quote
We here at DavePCGuy have finally launched our first independent website, done completely without an outside sponsor!
It’s called Only A Quote. Basically, what it is, is a database of quotes from different kinds of places (added one at a time to ensure quality) where the users only see a single quote with a random button [...]
CSS3 Lesson 3: Background Information is Essential
December 16, 2009 - 21:34
Tags: css, Design, formatting, lesson, webpage, website
Posted in HTML/CSS, Tutorials | 4 comments
Let’s have a look at backgrounds. In the previous two tutorials, I’ve covered borders and opacity. In this tutorial, we’ll cover some of the basic CSS3 additions to the background properties. If you have no idea how to deal with backgrounds in CSS, read my tutorial on backgrounds pre-CSS3. CSS3 is gaining momentum in the [...]
CSS3 Lesson 2: All About Borders
December 3, 2009 - 10:38
Tags: border, css, formatting, internet, lesson
Posted in HTML/CSS, Tutorials | 3 comments
Okay, I’ve noticed some REALLY cool stuff on CSS3 online, so I thought to myself, how about I make my own experiment and teach you all about how to use this stuff?
Here are a couple of resources I’m using to learn about CSS3:
CSS3 Info
CSS3 Validator
Intro to CSS3
W3 Avenue
Net Tuts Plus tutorial
I’ll start with the topic [...]
Success!
December 1, 2009 - 11:20
Tags: webpage, website
Posted in Personal | 2 comments
Okay, I have to thank all of our readers and people that have supported us along the way! It has been over three months now since we launched DavePCGuy.com
Since our launch, we have published 47 distinct, separate, and awesome blog posts! Most of them have been PHP or CSS tutorials and it was quite a [...]
CSS Lesson 7: Border Radius and Opacity
November 19, 2009 - 16:46
Tags: background, css, lesson, text, website
Posted in HTML/CSS, Tutorials | 4 comments
Border Radius and Opacity
I’ve noticed some hundred tweets on CSS3, every day. Check out the CSS3 Watcher for random updates. They actually mention really awesome and useful tutorials. So now, let’s look at some basic features that actually work cross-browser (with some tweaks). You can check some of the usage on two version of [...]
CSS Trick: Disappearing Textbox
October 30, 2009 - 11:21
Tags: css, formatting, project, text, web extras, webpage, website
Posted in HTML/CSS, Tutorials | 4 comments
Remember that trick to show a sub-menu using CSS in my older tutorial? Well, I had an idea for a project of mine, and with a little help from my dear friend Raphael. Last night, I launched my little website project called “A Night Story” and made some tweaks. Ignore the story, it’s just a [...]
CSS Lesson 6: Intro to Divs
October 25, 2009 - 17:36
Tags: css, Design, divs, formatting, lesson, text, webpage, website
Posted in HTML/CSS, Tutorials | 5 comments
Alright, alright. So I skipped all that fuss with horizontal navbars but that stuff is easy so I’ll create a short article on it later.
Let’s start with the <div> tag. It’s what I’ll be covering. Making use of div’s with CSS. You’ll need to know the following before we start the lesson:
CSS Lesson 2
CSS Lesson [...]
CSS Vertical Navigation
October 8, 2009 - 17:30
Tags: css, formatting, lesson, navigation, text, webpage
Posted in Design, HTML/CSS, Tutorials | 1 comment
CSS Vertical Navigation
The List
The CSS
Sub-Menu
Finally! Let’s check out vertical navigation. This tutorial will cover different tips and tricks on creating the vertical navigation bar. You can read my article on Color Theory and about Color Scheme Designer for more info on picking colors for your navbar. Most navbars, as I’ve heard, depend on javascript for [...]

