Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How do you structure your forms?

Featured Replies

Sup?

I wanted to ask what method you prefer for structuring forms? I learnt CSS initially from the the APress book "Beginning CSS Web Development: From Novice to Professional", and it describes several methods: table, definition lists or standard paragraph/header formatting. The author tentatively suggests that in this instance, tables are a simpler way to control form layout.

 

What say you?!

I would say I structure like this:

 

<form action="email.php" method="post">
<label>Email:</label>
<input name="email" size="30" type="text" />

<label>Message:</label>

<textarea cols="40" rows="15" name="message">
 </textarea>
<input type="submit" />
</form>

I have only really tried one format using form, fieldset, legend, the inputs (whatever they may be), and I have used paragraphs and then css for layout.

 

If I'm completely honest tho, it doesn't look exactly as I'd like.

  • Author

JFTR - what I'm asking is how you style forms (i.e: do you tag form elements directly, or do you house them in another html element), not how to create the form itself.

  • Author

er....nope -

 

Okay let's rephrase the question one more time:

 

By default, you are an advocate of semantic markup and use external CSS. Yet when it comes to forms, there are several methods with which you can structure your HTML document. You can use the bare form syntax, or you can house the form elements in side other html elements, such as a definition list, a table or paragraph/headers.

 

for example - sitepoint has this tutorial that uses a table for layout:

http://www.sitepoint.com/article/style-web-forms-css/3/

 

alistapart uses unordered lists

http://www.alistapart.com/articles/prettyaccessibleforms

 

and a whole bunch of other methods are listed here.

http://www.smashingmagazine.com/2006/11/11...dern-solutions/

I wouldn't use tables.

 

Lists seem to be popular but it doesn't seem semantic

 

Perhaps just divs and fieldsets?? Depends on how complex the form is..

I think tables are the easy way to go, and despite being not semantic use of code, I wouldn't punish anyone for doing so. Having said that, I'm somewhat of a purist when it comes to doing things as they should be done, so for me its fieldsets, divs, what have you. It isn't easy to get right though.

  • Author
I wouldn't use tables.

 

Lists seem to be popular but it doesn't seem semantic

 

Perhaps just divs and fieldsets?? Depends on how complex the form is..

 

That's why I ask the question, because the Apress book and author is most certainly pro standards/W3C/semantics, but shows three methods, of which one (and the one he appears to prefer) is table based. I thought - "that's odd".

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.