| | |
Tech, Life, & Stuff…

A Blog by Franklin Pettit

July 29, 2008

The HTML Fieldset

Posted by : Franklin Pettit
Filed under : HTML

This is just a quick post about something I learned the other day. Do you learn everyday on the internet? I do. I thought I would share something very simple that some bloggers might want to use.

What is an HTML fieldset and why would you want to know? W3schools defines a the fieldset element as follows:

“The fieldset element draws a box around its containing elements.”

This is a fieldset:

Text In Fieldset Example Fieldset:

What is good for? Does it kind of look like a VB frame? Possible uses could be as a text accent, a text format, or most commonly at the bottom of a blog post for related items. Many bloggers use plugins to generate a list of related posts.

The code for the fieldset is simple. Here is the code for the example above:

<fieldset>
<legend>Example Fieldset:</legend>
Text in Fieldset
</fieldset>

See I told you it was simple. Now fieldsets like almost any piece of HTML can be formatted with CSS. You can format the box any way you like. But I will not discuss that here. Let’s keep it simple.

If you want to add a box at the bottom of your post a list of links the Fieldset should do the trick.

Links & Related Posts:

No TweetBacks yet. (Be the first to Tweet this post)

  • Interesting tip, Franklin. Like you, I like learning and do it every day...

    Using Firefox 3, and while I can see the fieldset on your blog - it doesn't come through in my Google Reader.
  • I do not know for sure but I bet it has something to do with Google Reader's
    CSS or how Feedburner creates my feed. The Fieldset isn't a perfect
    solution I just like the simplicity of the coding.
  • I think the most exciting part about fieldsets is that they make web forms much more user-friendly. This is especially important if you care about people with disabilities who browse your site. Fieldsets make your site easier to work with and therefore must be used in any form that has more than 6-8 elements.
blog comments powered by Disqus

  • July 29, 2008 at 7:40 PM martin english
    The trap of a multi-browser web :) Despite most references claiming it works in IE6, I have not been able to get it to work in as simply as you've defined in your post. See http://www.mattheerema.com/archive/getting-fieldset-backgrounds-and-legends-to-behave-in-ie for some solutions
  • July 29, 2008 at 7:45 PM Mark Trapp
    Martin: you can accomplish the same thing (albeit not semantically, but that's a lost pipe dream anyway) using divs. put a div around what you'd normally put a fieldset on, and give it a border via CSS. If you want a legend, create a div or another block element (maybe an h1/h2/h3/h4/etc.) with the legend at the top of the container, and give that div a negative margin-top via CSS. Fieldsets were only meant for grouping radio and checkbox items in a form; otherwise, you should be using CSS to present.
  • July 29, 2008 at 7:45 PM Mark Trapp
    The bonus of the method I described is that it works in all browsers.

Add a comment on FriendFeed




About Franklin

I coined this blog "Tech, Life, & Stuff" for lack of a better description. This blog is primarily about my view on tech from South Carolina. I am a South Carolina software developer. More>

My Tweets

  • @Corvida your TweetSuite plugin is pointing to @admin change it to @Corvida in the options. :) 01/23/09 06:16pm
  • RT FriendFeed: My Content Portal & Aggregator http://tinyurl.com/c4v3gm from: @corvida 01/23/09 06:15pm
  • @corvida yeah. Target brand chips are resealable but those are the only ones that I know of. 01/23/09 02:00pm
  • It’s a Windows 7 Love Fest http://ff.im/-J2T9 01/23/09 01:55pm
  • Writing From Shower Thoughts [feedly] http://ff.im/-J2T8 01/23/09 01:55pm