Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Covering diverse topics such as improving workflow and managing CSS styles, Dreamweaver CS3 Beyond the Basics is a hands-on course that teaches users how to move beyond standard, static websites. Instructor James Williamson explores how to increase productivity, interactivity, and accessibility with Dreamweaver. He also discusses how to extend the application's capabilities with XML and XSL. Exercise files accompany the tutorials.
In a previous exercise we gave layout definition to the input text boxes and their associated labels. In this exercise we are going to turn attention to stacking groups of checkboxes in vertical columns. Now as we look at our own form, just below our Name and Email input text fields we have I would like information about the following and then we have a group of four checkboxes, consultation, sculpture, paintings and photography. But right now they are not looking all that great and it's really hard to ascertain who is who and what pertains to what. So we are going to go ahead and style these elements visually in a two- column layout. We are going to do this by nesting each column of checkboxes inside a container div tag and then floating the checkboxes inside the div tags.
Now this may seem like non-semantic markup, and in a way that's true, but when you have a lot of checkboxes, these are only four of them but let's say you have 15 of them or 12 of them or 18 of them, grouping them is not a bad way of going ahead and passing along information about a subset of checkboxes. So we will switch over to Code View, because it's going to be easier to wrap items in Code View. Once we are in Code View what you are looking for in on line 45 I would like information about the following. We are going to start there. So I will start highlighting there and I will scroll all the way down and I need to make sure I am getting all my checkboxes.
Now I am going to highlight all the way down to around line 57. I want to make sure I don't get the line break with the class of clear because we are going to do some containing floats to this div. In doing that, it's going to allow it to expand so that the floated elements inside of it fit. So we don't want their float to affect anything below it, which is why we have that line break. So make sure you highlight all that and then we will use our Quick Tag editing shortcut. That's Command+T or Ctrl+T on the PC. I am going to type in div and we are going to give this one an ID and the ID of this div tag is going to be informationType, and we are going to use a T here so we are going to use camel code formatting. So hit Enter and it will surround all of that in the ID informationType. So that's exactly what we need to do.
Now the next thing we need to do is wrap the checkboxes themselves in div tags and if we look closer at it we have four of them. So we are going to split them in half and wrap two in one div tag and two in another. So I have scrolled down so that I can see all my input tags at the same time and I want to highlight not only the input tags but also the paragraphs that contain them. So I am starting with the first input name, which is consultation, and the second one, which is sculpture, highlighting both of those. We will go ahead into our Quick Tag editor again and we will type in div. This time, instead of assigning an ID we are going to assign a class.
This class is going to allow us to write styles that will affect every single group, instead of having to pass along a unique value each time. So classes can be used over and over again whereas IDs can only be used once per page. So I type in class="group1" so we're coming for the very generic sort of grouping name. So div class="group1". Highlight the remaining two inputs and remember to highlight all the way down to the closing paragraph tag of the last one. So you are going to be right in front of the closing div tag and let's again bring up your Quick Tag editor, Ctrl+T or Command+T, and we are going to do div class="group2". So we have group1 and then we have group2. I am going to hit Enter.
I am going to save the file, switch back to Design View and structurally our checkboxes are now ready to be styled and you can see that that really didn't take a lot of work. We just basically use three div tags, one to contain our checkboxes and then a div tag for each column that we are going to create. So we will switch back over to the contact _secondary.css and just below where we have been creating some styles for our labels we will go ahead and create another section. I am going to add the following rule, #informationType. So that's the div tag we just created. Go ahead and open up a curly brace and you want to type in margin. We are going to pass two margin values in. We are going to pass in a 20-pixel margin for the top and bottom and then for left and right we are going to pass in 0.
What it's doing is it's helping give us a little bit of space above and below our checkboxes, so it's just sort of spacing our format a little bit. Let's go down to the next line and this time we are going to go ahead and add a comment, so you can do it using your Code toolbar, you can hand-code it and our comment is going to say display labels inline with checkboxes. So we are being pretty descriptive here about what it is that we are doing. And right below that we are going to write a grouped selector, type in #informationType label. Notice that we are writing in descendant selector here.
We are saying any label element found inside of an element with an ID of informationType. Type in a comma and then #artistinfo. That's all one word as well, label, and then open up a curly brace. So that second group of checkboxes already had a div tag around it and it's structured in the same way and that one has an ID of artistinfo. So we are basically just groping this together so that both sections of checkboxes will perform the same. We are going to say float, and we are going to pass a property of none into it and type in display:inline. Now, remember an inline display means that objects can display along the same line.
So what this is doing for us is it's making sure that the label and the checkbox can display on the same line and appear beside each other and that's typically how you want to see a checkbox or a radio button. So we will go down to the next line and we will type in padding-left and we will add a padding-left of 5 pixels and that will help our labels and our checkboxes have a little bit of space between them and we will close out that style. We have got one more style to go before we're finished and this is going to create our multi-column look. So I am going to type in another comment and I will type in align columns of checkboxes or radio buttons. That's one of the reasons why we use generic names, so this will work regardless whether you are using checkboxes or radio buttons. Most forms are going to have multiple sections of these, so going ahead and writing generic styles to control them is just a lot more efficient.
So we are going to type in div.group1, div.group2, div.group3. Now we didn't use a group3, but it doesn't mean that later on down the line we might have so many radio buttons or checkboxes in an element that we have three columns. So we are going ahead and writing a very expansive rule here that's going to give us a lot of flexibility in our form. We will go ahead and use a float:left property on that and it will float these div tags next to each other. We will go ahead and give them a width and we are going to give them a width of 15 ems. Now that's going to control the width of the columns and if you think the columns are too wide you can always come back and change that.
Then finally we will do a padding-left and this will help push it away from not only the edge of the form but also the edge of the previous column and we will give that a padding of 10 pixels. So again we will save this, we go back to our contact form and as we can see our checkboxes are now laying out in a multi-column display. Just to make sure let's test that in our browser and as we preview our form is starting to take shape. It's not totally finished yet but it's getting there. So now we have checkboxes in two-column layouts and again we know that we can adjust their width, we can adjust the spacing of them, we are controlling all that through Cascading Styles.
So our text input boxes and the labels now line up. We have clearly defined width and structure, our checkboxes not only lined up in two columns but their labels are also correctly displayed to the left preceding its checkbox. So our form is really starting to look the way we want it to look. So next, we will further enhance our form accessibility and the user friendliness by giving a little bit of user feedback on which items in our form are required.
Find answers to the most frequently asked questions about Dreamweaver CS3 Beyond the Basics.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
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.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.