Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
James Barnett
39,199 PointsAdding a Contact Form video - Uses Tables :(
So I was watching the Adding a Contact Form video in the PHP course and Randy is using tables for forms.
I think a preferable solution is to use <fieldset> and <p> elements instead of tables. It appears that with the advent of HTML5 the W3C concurs using <fieldset> and <p> for forms is now the recommend method.
So to compare and contrast these 2 methods, I've created a pair of codepens, one with and one without tables.
I'm curious to hear others thoughts on the matter.
7 Answers
Randy Hoyt
Treehouse Guest TeacherHmmmm ... looking at the HTML5 spec for "paragraph," I found this:
A paragraph ... can ... be used for more general thematic grouping. For instance, an address is also a paragraph, as is a part of a form, a byline, or a stanza in a poem.
That seems a crazy to me: a label and field pair is not a paragraph. ("That word does not mean what you think it means." :~)
I feel that a table here is more semantic. If I were to display the results of the form submission, I would definitely use a table:
Name | Mike the Frog
Email | orders@shirts4mike.com
Message | Hey Randy, How would you mark up a form?
The values in the left column are clearly headings for the values in the right column. When the data is entered in, it seems like it has the same semantic relationships.
Name | [________]
Email | [________]
Message | [________]
You wouldn't display the results in paragraph tags!
But looking at the spec as it currently stands, it definitely sees a label and a field pairing as a "paragraph". I may have to switch to using what I consider "inferior markup" because it's the accepted way of doing things. :~)
Thanks for bringing this up, James. Let me think about this some more.
James Barnett
39,199 Points@Randy -
I think an argument could be made that a <dl> is a semantic choice.
That seems a crazy to me: a label and field pair is not a paragraph. ("That word does not mean what you think it means." :~)
If you think that's a strange defination of paragraph, you should read what the HTML5 spec has to say about the terms header and footer. But that's a much longer dicussion for another thread.
Randy Hoyt
Treehouse Guest TeacherGood point: the HTML5 spec is full of words that don't mean what anyone would think they mean. :~)
I like a <dl> here, as well. In HTML5, they've changed the meaning of that tag from definition list to a description list (spec); this opens it up to a much wider range of usages.
Randy Hoyt
Treehouse Guest Teacher@James, I just saw your Codepen title for the <dl> example: "Tableless Form." What do you have against tables? :~)
James Barnett
39,199 Points@Randy -
I just saw your Codepen title for the <dl> example: "Tableless Form." What do you have against tables? :~)
I've got 3 codepen's actually, a table-based form, a tableless form - using <p> and tableless form using <dl>
Randy Hoyt
Treehouse Guest TeacherI prefer the "paragraphless form using <table>" and the "paragraphless form using <dl>". :~)
James Barnett
39,199 Pointsparagraphless form using <table>
That made me LOL