Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Basic form styling

From: Dreamweaver CS5 Essential Training

Video: Basic form styling

Now that our form structure is nearly complete, we can concentrate on making it fit to visual design of our site. We'll do this by writing styles that target individual form elements and by taking advantage of the additional structure we added to our form with the fieldset and legend tags. So here I have the join.htm file from the 12_12 explorers directory open and we're going to start adding some styles. Now prior to this chapter, we've primarily worked with our CSS through either the CSS Styles panel or the New Rule Definition dialog box.

Basic form styling

Now that our form structure is nearly complete, we can concentrate on making it fit to visual design of our site. We'll do this by writing styles that target individual form elements and by taking advantage of the additional structure we added to our form with the fieldset and legend tags. So here I have the join.htm file from the 12_12 explorers directory open and we're going to start adding some styles. Now prior to this chapter, we've primarily worked with our CSS through either the CSS Styles panel or the New Rule Definition dialog box.

Well in this chapter we are going to do something little different. We are going to go in and we are going to start hand coding our styles. Now I know for a few of you, that may have quickened your pulse a little bit. You may be little nervous about that, but trust me about something. Hand coding is one of the best ways to quickly gain a comfort level with a certain technology, CSS especially. It's going to help you learn the syntax of it. It's going to help you feel comfortable going in and making those tweaks and edits on your own. It's also going to help you understand the overall structure of your CSS code and how it relates to everything else.

There's really no substitute for getting in there and sort of working with that code and learning it yourself. If you're brand-new to Dreamweaver, if you're brand-new to hand coding, don't panic. Dreamweaver gives us a lot of really cool tools. That's going to help us make sure that our syntax is correct. Plus we are going to go slowly through all the lines of code, talk about what they're doing for us and why we're writing a specific line. So hopefully you'll find this process just as instructive as working with the CSS Styles panel as well. So what I am going to do in order to sort of prepare for this, I am going to collapse my panels down to icons and then I am going to switch to a Split Screen View, so that I can see my CSS on one side and my design on the other.

Now I am going to scroll down so that I can see my form, so I can kind of watch and see what's going to happen with that. And over in the Code pane if you don't see what, I see go up right up here to the document that you have opened, join, find the related files, which is listed just below that, and click on main.css. That will make sure that it's focusing on this code. Now one of the reasons why I'm hand coding is because our CSS has sort of an empty block where our form styles need to go. So I want to make sure that those go in the right place and I want to be able to inspect these styles maybe a little bit more closely than some of the other styles we've written.

So I am going to scroll through my code and go all the way down to line 654. Now that's a lot, but that's fairly standard for a lot of sites out there. As a matter of fact there are a lot of sites out there that have three times this amount of code. All right, so what about line 653, you can see that we have a couple of comments. There little gray lines of code here. /* and ended by a */ is a comment. They are not processed by browsers. They are just ways of a sort of talking to ourselves or in this case organizing our code.

So our form styles are going to go right below the line 653 and then we have individual form areas for code. On another page we have a support form and a contact form and here is the area where our join form styles are going to go. Later on after you have done with this chapter, go to the clean site folder within our exercise files, open that up, and check out those other forms and why they needed some individual styling as well. Okay, well let's start with an overall form styling. I am just going to type in the selector on line 654. I am going to type in #mainContent.

that's all one word, lowercase m, uppercase C, space form. So we are targeting any form element inside of the mainConcent region. Open a curly brace. You'll find those just to the right of the P key. You have to hold the Shift key down to get them and then hit Return to go down to the next line. You can see automatically Dreamweaver is bringing up a list of properties that we can choose to set. Type in an F and then O and it will jump down in the list of font. That's what you want. So type in F and an O, then you should be able to hit Return and Dreamweaver will finish that for you, and you will see a colon. So for our font, I want you to type in normal, then a space, .9ems, so normal meaning we don't want it italicized, we don't want it bold, and then another space and then type in an A and you'll Arial, Helvetica and sans- serif. Go ahead and select that, type in a semicolon to end that property, go down to the next line ,and here you want to type in color and the color is going to be #193742, so 193742. Type in another semicolon, hit Return and close your curly brace. So you want an opening and a closing curly brace to surround those properties.

Now to learn a little bit more about the syntax of what we are writing here, be sure to go up and watch the chapters on typography and on layout that deal with CSS as well as any of the other CSS-based titles in the lynda.com Online Training Library. Okay if I click inside my form now, I can see that the text changes to Arial and it changes to that sort of darker blue color. So we are well on our way. Now let's take advantage of the fact that these forms have separate areas defined by fieldset tags. So I am going to go up to my form styling in my CSS and just below the rule that we've just created, make sure that you don't get rid of and that you're outside of that last closing curly brace there.

We type in #mainContent, space fieldset. So fieldset is one word. Open up your curly brace and on line below that, we are going to set some padding. So type in p-a, padding will come up. You can hit Return and it will finish it and you want to do 40 pixels 20 pixels 0 0. So that's going to give us 40 pixels worth of padding at the top of the fieldset. It's going to give us room for our legend tag to show up. We have 20 pixels worth of space to the right of our fieldset, zero on the bottom, and zero on the left.

So it's just giving a little bit of padding on the top and on the right. Hit Return to go down to the next line, and here you want to set your margin, and our margin is going to be set to zero, zero, 2em. So the zeroes here again, top margin of zero, right and left margin of zero, bottom margin of 2em. So essentially it's just going to push these fieldsets away from each other so that there's a little bit of space in between them. We are going to do a background color, and the background color here is going to be #e1d8b9.

On the next line we are going to do a border. Our border is going to be none and that's going to take away any default border, so every browser displays a fieldset as having sort of a gray border around it. We don't want that. Then we are going to do a position property of relative, so that we can position items within the fieldset using absolute or relative positioning. And then finally, we're going to do a float and we are going to float this to left. Now the float really isn't for our forms. It's for the other forms but we are leaving it in there just so that it will work for our site-wide. We don't really need that for our particular form.

In fact you can see it's causing some real issues with our form as these fieldsets we're stacking right beside each other. So we've got to fix that in just a moment. All right let's keep going. One of the most difficult HTML elements to style, if not the most difficult, is the legend tag. The legend tag just kind of does its own thing and different browsers allow different properties to actually affect it. So what we are going to do is kind of we have some default styling for our legend tag and then maybe going and tweak that a little bit to see if we can't place it a little bit more precisely.

I am going to go down to the next line and I am going to type in #mainContent fieldset legend, so that's the legend tag directly inside of the fieldset. We are going to give it a padding of zero, don't forgot my semicolon there, a margin of zero and then I am going to assign a color, something little different than rest of the form, #51341a. So 51341a, it's sort of a brown color.

Don't forget to close your rule out and now if you click back over in your form, you can see that the legends of change colors. They are more of a brown color now. Now one of the things that's really difficult about styling legends within fieldsets is positioning them. They want to show up in the upper left- hand corner and every browser has their own way of positioning them. You would think just sort of zeroing everything out and then telling the legend where you wanted to go would work. Unfortunately, browsers, and in this case most notably Firefox, don't allow certain types of positioning to occur to legend tags. So sometimes you got to be a little tricky.

What I would like you to do is go over to Design View and highlight each of the legends. Personal Information is first. Make sure you look at your Properties Inspector and you are on the HTML tab and click the Bold icon. That is going to basically throw a strong tag around each one of these legends. I am going to do the same thing for Login Information and I'm going tp have to scroll down but I am going to do the same thing for Tour Profile. So each one of these should now look bold and that's good because we kind of want it like that, but more importantly it means they have a strong tag around it and we can now actually go ahead and style that.

So what I am going to do is focus back on our Code View, go down the next line, and here I am going to type in #mainContent fieldset legend strong. And to be honest with you we don't really need to fieldset there. You could have just said mainContent legend strong, but it helps us understand kind of how it relates to the selector above it. I am going to go down to the next line and I am going to position this using absolute positioning. If you want to know more about absolute positioning, watch the chapter on CSS layout where we talk about it in a little bit more detail.

Then we are going got do a margin-left of 20 pixels. We are going to do a margin-top, and you can just scroll through those lists if you would like, of 10 pixels and then finally a font size, so font- size not just font, but font-size of 1.2ems. Go ahead and close your curly brace there. Now when you click, it's not really going to look that good in Design View, so we're done we are going to preview this in our browser to see where it positions the legend.

Now you might be wondering, well when we use positioning we use offsets, so left and top, why margin-left and margin-top? Well again, it's getting around some of these browser bugs and browser errors out there. Instead of using offsets, we're going to use margins to position it, but the absolute position around the strong tag allows us to move it at all. So its one of those closings were it's not an ideal selector and at first glance it doesn't make a whole lot of sense, but it does work. Okay we have one last thing left to do here in this stage of formatting. I am going to go down into our individual forms and since each of our forms is different in width and where its found and how it reacts, a lot times what you are going to want to do is for a specific form, say okay for this form, I want all my elements in it to look like this or I want its width to be this and that's why we have a separate section down here for our join form. And that's the one we are currently working on.

So here I want you to type in a selector that says #mainContent space form and no space here #frmJoin. Now a word about this. This is what we call an element specific ID selector. It's saying when you find the ID frmJoin on a form inside of mainContent, so that's what it's basically saying and remember we named that form frmJoin. All right another space and then type in fieldset. So we are targeting the fieldsets that are only found in our join form.

Go down to the next line and type in width 580 pixels. So we're setting an explicit width for our fieldsets to 580 pixels. When we do that the form behaves itself a little bit better. So go ahead and do a Save All, preview that in a browser, and you can kind of see what we have done to our form. Our fieldsets are now individual regions that are separated using the margin, the legend is positioning itself inside the fieldset instead of right on the edge, and we have given ourselves a little bit of spacing between that.

You will notice that this initial styling helps the overall structure of the form but it does absolutely nothing for the individual form elements and that's what we are going to have to tackle next.

Show transcript

This video is part of

Image for Dreamweaver CS5 Essential Training
Dreamweaver CS5 Essential Training

135 video lessons · 89634 viewers

James Williamson

Expand all | Collapse all
  1. 2m 57s
    1. Welcome
      1m 8s
    2. Using the exercise files
      1m 49s
  2. 7m 50s
    1. What is Dreamweaver?
      3m 16s
    2. Learning web design
      2m 22s
    3. Current web standards
      2m 12s
  3. 43m 9s
    1. The Welcome screen
      4m 5s
    2. Windows and Mac interface differences
      2m 23s
    3. The Application toolbar
      4m 7s
    4. The Document toolbar
      4m 40s
    5. Arranging panels
      8m 19s
    6. Managing workspaces
      7m 32s
    7. The Properties Inspector
      5m 54s
    8. The Insert panel
      6m 9s
  4. 25m 45s
    1. Basic site structure
      3m 11s
    2. File naming conventions
      1m 49s
    3. Defining a new site
      4m 35s
    4. Managing sites
      4m 51s
    5. Managing files and folders
      6m 36s
    6. Working with browsers
      4m 43s
  5. 27m 21s
    1. Creating new documents
      5m 16s
    2. New document preferences
      3m 6s
    3. Setting accessibility preferences
      4m 56s
    4. Working with starter pages
      3m 46s
    5. Managing starter pages
      10m 17s
  6. 30m 2s
    1. Basic tag structure
      2m 15s
    2. Adding structure to text
      8m 20s
    3. Creating lists
      9m 59s
    4. Getting text into Dreamweaver
      5m 59s
    5. Importing Word documents
      3m 29s
  7. 1h 17m
    1. Understanding style sheets
      2m 16s
    2. The anatomy of a CSS rule
      1m 48s
    3. Setting CSS preferences
      6m 36s
    4. The CSS Styles panel
      10m 2s
    5. Controlling CSS through the Properties Inspector
      5m 14s
    6. Using the Code Navigator
      7m 21s
    7. Using CSS Enable
      6m 45s
    8. Understanding element selectors
      8m 11s
    9. Understanding class selectors
      8m 49s
    10. Understanding ID selectors
      5m 59s
    11. Understanding descendant selectors
      6m 51s
    12. Attaching external style sheets
      7m 44s
  8. 1h 47m
    1. Working with units of measurement
      7m 11s
    2. Declaring font families
      9m 39s
    3. Controlling font sizing
      9m 9s
    4. Controlling weight and style
      8m 0s
    5. Controlling line height
      8m 29s
    6. Controlling vertical spacing with margins
      12m 3s
    7. Controlling spacing with padding
      5m 39s
    8. Aligning text
      8m 26s
    9. Transforming text
      5m 36s
    10. Writing global styles
      15m 42s
    11. Writing targeted styles
      17m 37s
  9. 1h 32m
    1. Understanding image types
      5m 3s
    2. Managing assets in Dreamweaver
      12m 51s
    3. Setting image accessibility preferences
      4m 20s
    4. Setting external image editing preferences
      3m 52s
    5. Placing images on the page
      7m 37s
    6. Photoshop integration
      5m 54s
    7. Modifying Smart Objects
      5m 51s
    8. Alternate Photoshop workflows
      8m 8s
    9. Modifying image properties
      11m 14s
    10. Styling images with CSS
      7m 11s
    11. Using background graphics
      9m 3s
    12. Positioning background graphics
      11m 6s
  10. 55m 16s
    1. Link basics
      3m 37s
    2. Setting site linking preferences
      2m 14s
    3. Creating links in Dreamweaver
      11m 1s
    4. Absolute links
      5m 8s
    5. Using named anchors
      11m 19s
    6. Linking to named anchors in external files
      2m 44s
    7. Creating an email link
      5m 24s
    8. Creating CSS-based rollovers
      13m 49s
  11. 1h 34m
    1. CSS structuring basics
      2m 56s
    2. The Box Model
      13m 21s
    3. Understanding floats
      6m 53s
    4. Clearing and containing floats
      8m 56s
    5. Using relative positioning
      4m 8s
    6. Using absolute positioning
      7m 18s
    7. Creating structure with div tags
      12m 7s
    8. Styling basic structure
      10m 34s
    9. Creating a two-column layout
      10m 37s
    10. Using Live View and CSS Inspect
      7m 51s
    11. Using Browser Lab
      9m 39s
  12. 56m 22s
    1. Reviewing table structure
      7m 41s
    2. Importing tabular data
      5m 13s
    3. Creating accessible tables
      9m 56s
    4. Using thead and tbody tags
      4m 0s
    5. Basic table styling
      8m 45s
    6. Styling table headers
      7m 52s
    7. Styling column groups
      4m 22s
    8. Creating custom table borders
      5m 1s
    9. Styling table captions
      3m 32s
  13. 1h 43m
    1. How forms work
      3m 0s
    2. Reviewing form design
      3m 2s
    3. Creating accessible forms
      7m 33s
    4. Setting form properties
      4m 6s
    5. The fieldset and legend tags
      4m 32s
    6. Inserting text fields
      5m 58s
    7. Inserting list menu items
      5m 26s
    8. Inserting checkboxes
      7m 50s
    9. Inserting radio button groups
      6m 22s
    10. Inserting text areas
      4m 12s
    11. Inserting submit buttons
      3m 37s
    12. Basic form styling
      12m 0s
    13. Form element styling
      8m 52s
    14. Styling form layout
      11m 49s
    15. Adding form interactivity
      2m 47s
    16. Using Spry validation widgets
      12m 49s
  14. 1h 23m
    1. Planning for templates
      10m 51s
    2. Creating a new template
      10m 37s
    3. Using editable attributes
      13m 43s
    4. Creating optional regions
      6m 23s
    5. Creating new pages from a template
      9m 17s
    6. Applying templates to existing pages
      6m 9s
    7. Working with nested templates
      7m 56s
    8. Working with repeating regions
      12m 58s
    9. Modifying templates
      5m 41s
  15. 40m 14s
    1. Behaviors overview
      3m 47s
    2. Hiding and showing elements
      9m 18s
    3. Spry overview
      4m 4s
    4. Using Spry widgets
      11m 36s
    5. Adding Spry effects
      3m 6s
    6. Using the Widget Browser
      8m 23s
  16. 28m 18s
    1. Inserting Flash files
      5m 4s
    2. Setting properties for Flash
      6m 27s
    3. Dreamweaver and Flash integration
      6m 6s
    4. Encoding Flash video
      6m 10s
    5. Adding Flash video
      4m 31s
  17. 45m 28s
    1. Running site-wide reports
      6m 33s
    2. Checking for broken links
      5m 41s
    3. Checking for browser compatibility
      8m 3s
    4. Adding remote servers
      8m 0s
    5. Uploading files
      7m 20s
    6. Managing remote sites
      9m 51s
  18. 34s
    1. Goodbye

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Dreamweaver CS5 Essential Training.

Return to your organization's learning portal to continue training, or close this page.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.