Tip: Styling the label element with CSS

More about styling form elements, this time the label element . . . .

A few days ago I wrote  Tip: Styling a Fieldset with CSS. I decided to add to the small form I used and provide another tip on how to style the label element.

I made a few changes to the HTML example I’d used in the previous example. Here’s the new HTML page, with CSS. The changes result in this appearance for the form.

the styled labels in the form

In the HTML, I changed the labels to include the “for” attribute, so that I could move the closing label tags from where they before. The code is now like this for each label:

<label for="name">Your Full Name</label>
<input type="text" name="name" id="name" />

I also moved the submit button out of the fieldset, since it really didn’t belong in there in the first place.

I added the CSS to make the input fields appear as you see in the image (or on the example page). I made the labels display as block level elements, which were floated to the left. Then I assigned a width to the labels so that the input fields would all be a uniform distance away from the labels. I assigned a color and made the text bold. I used generated content to add a colon ( : ) after the label. (The colon may not appear in every browser.) Here’s the CSS.

label {
color: #B4886B;
font-weight: bold;
display: block;
width: 150px;
float: left;
}
label:after { content: ": " }

Those are the only changes needed to the form as it was described in the post about  Styling a Fieldset with CSS.

Review: Build Your Own Web Site the Right Way Using HTML and CSS

A review of Build Your Own Web Site the Right Way Using HTML and CSS by Ian Lloyd is from Sitepoint (2008). More . . .

by Web Teacher
Get this book at Amaon.com

★★★★★ Build Your Own Web Site the Right Way Using HTML and CSS by Ian Lloyd is from Sitepoint (2008). This is the 2nd edition. The first edition was on my recommended list for a very long time, and I don’t see any reason to remove the second edition from that recommended list.

The book covers the basics of getting started, tools you need, and gives plenty of examples of code for both the HTML and CSS it suggests. You build a single site to completion by the end of the book with a customized Blogger blog added. The book is a foundational experience that emphasizes best practices and would get anyone off to a solid start. The last chapter deals with where to go next, what else to learn, and where to find more references.

When tools are involved, such as FTP tools, the book includes examples for both Windows and Mac. It’s well written and illustrated. In short, a very good book

Summary: Clear explanation of the basics using best practices.

Technorati Tags: ,

Useful Links: Playing for Change, 300+ WordPress tools, Text Zoom

Links to Playing for Change, a worldwide music project, 300+ WordPress tools. Accessibility tips. More…

Playing for Change is a worldwide multimedia music project, bringing musicians from all over the world together by digital magic to create wonderful  music for a web site, a YouTube site, an album, and iTunes videos. The program brings supplies, facilities and education to musicians around the world. I realize it has nothing to do with teaching or learning web design, but it’s clearly a project that could not have been achieved before the advances in technology that support it.

WordPress God: 300+ Tools for Running Your WordPress Blog. Who could resist a list like this? Only someone using Blogger or Typepad would pass up this gem.

Check your design with text size increased to 200 percent from 456 Berea St is good advice  to teach all students as a standard part of their routine checks of every page they design.

Twitter in education

Rachel Reuben, writing at .eduGuru, asks Is Your University Using Twitter to Its Fullest Potential? She makes excellent points about how universities can monitor Twitter for mentions of special programs or their university, how they can set up accounts to manage outreach on Twitter for the university, and how to begin Twitter conversations helpful to the university.

What she doesn’t mention is using Twitter during class. Using the backchannel during class, if you will. I’ve been thinking about this article at Pistachio Consulting: How to Present While People are Twittering. It’s about conference presentations, but it could easily be about classroom presentations. Also worth thinking about is Olivia Mitchell’s Is Twitter a good thing while you’re presenting? One idea she mentions is the one-liner “Tweetbite” or a big concept that’s quotable in 140 characters.

What if you monitored the backchannel among your students while you were lecturing–see their questions, thoughts, confusions–while you were talking?

Is anybody doing this?

Tomorrow on BlogHer, I’ll be writing more about the backchannel. I’ll add a link here at that time. On BlogHer: The Audience is Tweeting.

Tip: Styling a fieldset with CSS

A small form with a styled fieldset to give you some ideas about how to punch up the appearance of a form. More . . .

A form element that will help you organize and clarify a form is the fieldset element. A form can contain more than one fieldset. For example, there might be a fieldset containing the form elements for the user’s personal information: name, email, etc. Another fieldset might collect information about a question, a product, or a service. Depending on the purpose of the form, fieldsets can help break it up into meaningful chunks and visually distinct areas.

click image to see the HTML page

Click the image to see the actual HTML page. (The form is nonfunctioning, submit won’t get you anywhere.)

The form in the example contains one fieldset. It’s simple, but it’s enough to illustrate the point.

Here’s the code for the fieldset:

<fieldset>
<legend>Reserve Your Space</legend>
<p>
<label>Your Full Name
<input type="text" name="name" id="name" />
</label>
</p>
<p>
<label>Email
<input type="text" name="email" id="email" />
</label>
</p>
<p>
<label>Phone
<input type="text" name="phone" id="phone" />
</label>
</p>
<p><input type="submit" name="button" id="button" value="Submit" />
</p>
</fieldset>

Look at the various elements in the form. These elements can be styled: fieldset, legend, p, label, input. (The p elements aren’t necessary, the example could use br or div instead. And, in most forms, the submit button would not be part of a fieldset, particularly if the form had more than one fieldset, which is a very likely scenario.)

Any rule of CSS can be applied to any or all of the form elements present. You can write rules for fonts, colors, background, background-image, line spacing, padding, margin, border, or anything else you might want to present in a particular way.

These are the CSS rules I wrote. You could do this many other ways.

fieldset {
border: 1px solid #CCA383;
width: 50%;
background: #FFE8EF;
padding: 3px;

}
fieldset legend {
background: #CCA383;
padding: 6px;
font-weight: bold;
}

Some simple touches with CSS involving color, padding, and border make the legend stand out and visually emphasize the form on the page.

See also: Styling the Label Element with CSS, which contains the same fieldset with additional styling for the label elements. Also see Three examples of fieldsets styled with CSS, which gives some very different fieldset examples.

Useful Links: 224 Layouts, the Whuffie Factor, WP Plugins

A new source for CSS layouts, get the Whuffie Factor in your social network, a great WordPress plugin for your clients. More . . .

CSS Layouts: A collection of 224 CSS Layouts available for downloading is from Jacob C. Myers. There is information about how to customize the layouts, and you can preview each one before you download. I can’t read the white text on the teal background at the top of the page, but I assume it would be informative if you could see it.

Event: Building your Business with Social Networks – The Whuffie Factor with Tara Hunt of Citizen Agency is a Carson Workshop in London in June.

Everyone knows about blogs and social networks such as Facebook and Twitter. And they’ve heard about someone who has used them to grow a huge customer base. Everyone wants to be hands-on, grass roots and interactive. But what does this mean? And more to the point, how do you do it?

KnowIT shared a nice WordPress plug in that allows you to put some instructions for a client right in their Dashboard. It’s the WP Instructions Plugin by Sam Burdge.

Useful Links: When Can I? Accessibility U

Useful links: When can I use new features of web standards? The John Slatin Access U for 2009. Do It Myself Blog’s Glenda figures out how to present live online. More . . .

When can I use . . . has compatibility tables for features in HTML5, CSS3, SVG and other upcoming web technologies. It shows a timeline for when various features will be supported. No surprise, many are waiting for the demise of some version or other of Internet Explorer.

An event to note. For two days in May, Knowbility will be putting on the newly named John Slatin Access U. It will be at St. Edward’s University in Austin, Texas. It features a Usability Track and a Molly Holzschlag Track. There’s a post conference day with Molly and Derek Featherstone. Read the course descriptions.

You know Molly’s a brand of her own when there’s a whole section of an event named “Molly Holzschlag Track.” There’s not even a need to explain what it will be about, you only need to mention her name. There’s an interview or a graduate thesis or a book in there somewhere about how Molly became a brand.

Celebrating a Newly Discovered Ability from Do It Myself Blog is Glenda Watson Hyatt’s presentation from AccessCamp San Antonio. It explains how she managed to do a live online presentation and is a must see presentation.