>> As we talked about earlier with headings the default appearance of certain HTML elements can deter people from using them correctly. If your not using real list because you need custom image bullets or other unique styles. It doesn't take much CSS to do that formatting and keep your HTML clean and semantic. Let's change the appearance of the list we created in the last movie. If you are using the exercise files then the name of the page is visitors.html and its located in the 04 11 folder inside the chapter four exercise files.
Let's create a new CSS file by clicking on the new CSS rule button at the bottom of the CSS panel. In the new CSS rule dialog box choose tag as the selector type. In the Tag Select menu click on the arrow and scroll down the list to choose UL, this will make the rule affect all unordered list on the page. Keep this document only selected in the define in option, then click okay.
The CSS rule dialog box appears lets start with some very simple styles for the list. Click on the list category on the left side of the dialog box. Then click on the Type menu. You'll see a number of options for standard bullet types. The default bullet for unordered list and most browsers is disc. Let's choose square, don't make any other changes at this point but just click okay.
In design view scroll down the page, the list is now indicated by small square bullets. We can see in the CSS styles panel that the name of the CSS property that controls the bullet type is called list style type. This is the same property that you would use to change the list marker type on an order list as well, say for instance if you wanted to change from numbers to letters. Now that we know how to make basic changes to our list styles lets look at some more unique things that we can do to style the list.
Click on the UL rule in the all rules listing o the CSS styles panel then click on the pencil icon on the bottom of the panel to edit the style by bringing up the CSS rule definition dialog box again. It opens with the list category by default the same category selected by default, the same category that we were on before. Select the Type menu again but this time choose none. This turns off all bullets on the list. We're going to use a background image instead to create the bullet.
You'll see under the Type menu that there's a field for bullet image, while you can use that field to set an image as a bullet for your list it doesn't allow you any type of precise positioning of that image and relationship to the list text. If we instead use a background image for the bullet on the list we have all the related background properties to control its appearance. Before we add that image though we need to change the default margin and the padding on the list, this makes sure that all browsers are starting off from the same baseline so that we can create the proper spacing and make sure our list text overlap our background bullet image.
So click on the box category and the CSS definition dialog box. Under padding keep the same for all box checked and then enter zero in the top field Dreamweaver fills in a value of zero for the rest of the sides. Under margin uncheck the same for all box, set the top margin to zero, the right to zero as well and the bottom box type 1.2 and for its unit select em's.
This ensures that sufficient space is left between lines of text no matter how big the font size is. Finally for the left value type 20 and leave the unit set to pixels. The amount of space to the left and right of this element does not need to scale proportionally with the text so that is why we are choosing pixels here instead of em's now click okay, you'll see that the list now has no bullets but it still is indented on the left side. The bullet background image needs to be added to each individual list itself.
So we need to create a new rule for the LI element. Click on the new CSS rule icon on the bottom of the CSS styles panel. Choose tag for the selector type then in the Tag menu scroll down and select LI form the list of text, keep this document only selected for the define in option and click okay. In the CSS definition rule dialog box choose the box category.
Under padding uncheck the same for all box and type zero for the top, right and bottom fields. In the left field type 16 and leave pixel set as the unit of measurement, this value creates empty space on the left side of each list item. This is where the background image will be positioned by setting the padding on the left side of the list item to be at least as big as the background image. We're ensuring that it will never overlap that image.
Under margin for all checked and then enter zero in the top field. Now click on the background category of the dialog box, here's where we can finally choose our background image. Click on the browse button, under look in navigate to the exercise files folder on your system. Go to the chapter four folder. Then chose the 04 11 folder inside that double click on the images folder from the list of images shown click on bullet_flower then click okay.
In the repeat field back in the CSS rule definition dialog box chose no repeat as the values. Just make sure the background image does not tile throughout the list item, it only shows once. For the horizontal position enter zero, this means we want to the back ground position to be all the way to the left side of the k=list item, choose percent as the unit of measurement simply because that's the unit of measurement we're going to use for the vertical position box. Click in that box now and enter 50 then choose percent from the unit of measurement field beside of it.
50 percent will keep the bullet vertically centered with the list item text, now click okay. The bullet image that we chose now shows beside each list item. You can use background images on list items in this way anytime you need a custom bullet. In the next chapter we will continue working with list but take the styles up a notch to turn list into navigation bars and menus.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Your file was successfully uploaded.