Viewers: in countries Watching now:
In Dreamweaver CS5 Essential Training, Adobe Certified Instructor James Williamson explores the tools and techniques of Dreamweaver CS5, Adobe's web design and development software. This course covers both the ins and outs of Dreamweaver, as well as recommended best practices for crafting new web sites and files, the fundamentals of HTML and CSS, and how to ensure clean and accessible code. The course also includes how to use tools in Dreamweaver to create and style web pages, manage multiple sites, and add user interactivity with widgets and scripting. Exercise files are included with the course.
In our last movie, we targeted some of the basic structural formatting of our form as we styled our form tag, our fieldsets, our legends. But we largely didn't style any of the interior form elements themselves. So in this movie, we will return to our styles and begin targeting specific form elements and styling them so that their labels and the form elements themselves fit visually in with the design of our page and with the desired visual flow to assist in usability. So I have got the join.htm from the 12_13 explorers folder opened.
And you may have already noticed, I have my Split View turned on. The form on the right-hand side in Design view and the CSS code on the left-hand side. So again, I can go right up to my related files, click on main.css, and then this time I'm scrolling down to about line 653, somewhere around in there. This is where all of our forms are. Okay. So now what we need to do now is we're going to concentrate on aligning our labels and our form elements together. One of the things that has always kind of amazed me is how many forms continue to be laid out using tables.
A lot of designers really don't want to tackle writing the CSS for laying out a form, because it can be a little tricky and so instead turn to its table structure. Now, there's nothing wrong with that. Plenty of designers do that. But it's not as accessible as using CSS because any user agent including screen readers still have to parse through the table and if you don't use the label tags correctly, a lot of the information can sort of get thrown away. So what we are about to do is to write some styles that are going to help our label and form elements line up and form an attractive layout without using tables.
Okay, so I am going to go up to my form styles and I am going at about line 676. I am going to hit Return and first we're going to tackle the paragraphs that are kind of the parent elements of the labels and the form elements themselves. Remember we surrounded each form element in a paragraph. I am going to type in #mainContent form p and then on a line underneath that I'm going to type in color and we're going to do #193742. Now that's the same color we placed on the form tag, so we don't really need it there. We are just sort of covering our bases in case some other nested style might try to override that.
And underneath that we're going to do a margin. So, we are going to do margin and we are going to do a top margin of 0 and then a space, right margin of 0 and then a space, bottom margin of 20 pixels so it's going to keep those elements away from each other by 20 pixels, and then a space, and then a left margin of 20 pixels. So that should hold all of our form elements away from the edge of the fieldset by 20 pixels and if I save this and click back on my form, I can see that indeed our spacing looks a little better now than it did before. Okay.
Now remember each of these form elements has a label that is associated with them and remember that the labels are found within the label tag. So now we're going to style our labels and try to create that sort of two-column look between the labels and the actual input text fields themselves. So going back into my CSS, on a line below that I am going to type in #mainContent form label, so targeting any of the labels in any form within the mainContent region. And what we are going to do is we're going to assign a width to those and we're going to give them a width of 100 pixels.
So you can take the label and say okay, you need to be 100 pixels wide. That means that the shorter ones, the longer ones, are all going to be exactly the same width. It's not going to stretch your text out. What it will do is sort of give a singular width for all of your labels so you won't have those ragged edges that we're seeing right now. Now, we're going to float these to the left, so do a float left and then let's do a clear left and then we're going to do a margin-right of 0.75ems and then we'll close that rule.
Now, what in a world is that doing? Well, remember from the chapter on layout, floats cause the objects underneath them to come up and float beside them. And in this case, it's going to help the text input fields float beside the labels and not stack one on top of the other. The other thing that the clearing is going to do for us is basically say don't let anybody float to my left and that's going to keep these guys from all stacking up on one line. The margin-right of 0.75ems is going to keep the form elements themselves away from the labels by a consistent amount.
And when I click back on my form, you can see exactly what's going on here. We are getting a two- column look from our form now. And let me point out, because I know you are probably looking at this and thinking wait a minute, Dreamweaver bless its heart, it has a hard time rendering that legend in place. So you just kind of have to get used to seeing it like that unless you want to click on Live View and if you turn on Live View and scroll back down to your form, you will see your form rendered the way it would be rendered within the browser. So again, we're seeing 100 pixel width for these guys and the best way to determine how wide you need that to be is take a look at your longest label and think about maybe how wide that is or how much space you really want to kind of play around with that.
And then the margin-right is sort of pushing our labels away from the form elements and giving us that sort of two-column look from that. Okay, now we still need to do some specific styling. That 100 pixels is probably going to work site-wide, but you will notice that we have a pretty large amount of space here and we have some very, very large labels. You can see we have these guys like From Desert to Sea and all those guys that are breaking down. Profile Bio. They can't fit within that space. So, what I am going to do is go down to my individual forms. After the Join form selector I am going to hit Return and here I am going to type in #mainContent form#frmJoin, once again that is all one word, space, label.
So now we are only targeting labels in this form, not site-wide. And so here what we're going to do is we're going to go ahead and do a width this time of 125 pixels. Let me do a Save All. I am going to click back in. You can see it pushes our form elements away from that a little bit more and that's really going to help us down here with our checkboxes. You can see it almost all fits within there now. We're almost done but I also want to address these textboxes themselves. Maybe I wan to make them a little bit wider or a little bit shorter and arrange them in the same order as well.
So, on the very next line in my Styles, I am going to type in #mainContent form#frmJoin. So remember it's saying any form with an ID of frmJoin and that's why we have no space right here and then another space and here we're going to type in input.text. So remember, these form elements are input tags. This .text if you remember from our chapter on CSS ,that's a class. So, we are basically saying if you ever find an Input text field with the class of text in this specific form, style it like this.
So go ahead and open a curly brace, hit Return to go down the next line, and what we're going to do here is we're going to give them a width of 200 pixels. Close that. And then just below that type in #mainContent form#frmJoin and if you are tired of typing those, you can always copy and paste the first part of the selector and then type in the rest of it. And then after that textarea, that is all one word. Textarea refers to the larger text field that we have down at the bottom that allows comments.
And we're going to give it a width of 500 pixels and give it a height of 150 pixels. And that is why we didn't bother to set a character width or a number of lines for that because we knew we were going to be tweaking that with CSS. Now since we were targeting Input text fields with only this class applied to it, we need to go back and apply that class. So, I am going to turn the Live View off. I can go back to just Design View and select each one of these text fields individually and using the Properties Inspector apply the class Text to it.
When you do that, you will notice that will extend out a little bit. It will get a little bit wider and that's going to assist with the usability, because it's going to give your users more room to type and more room for them to see what they are doing. It's only going to work with text fields, so that's all you need to do with that. So again, we are going to do a Save All and we're going to preview that in our browser. We're starting to get a nicely styled form. We've got two columns of labels followed by the text input fields. We didn't need a table to achieve that styling and our text area down here is the size that we were wanting it as well.
So we've added a great deal of styling to our form, but our form still lacks the overall structure that it needs. Our next task is going to be to finish the layout of our form by creating multiple columns in our form for these checkboxes and to ensure proper label positioning throughout.
Find answers to the most frequently asked questions about Dreamweaver CS5 Essential Training .
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.