/    Sign up×
Community /Pin to ProfileBookmark

Designed a form using tables, want to help me convert it to css? =)

[url]http://odna.net/adams/signguestbook.html[/url]

There it is ^^^

?

I’ve searched the boards, I’ve searched google, I’ve looked at how other people do it, and i’m really having a hard time trying to get it to work using pure css for the layout. I’m new to css though, so perhaps someone with css experience can help me out here… ?

Thanks in advance.

to post a comment
HTML

28 Comments(s)

Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — This has actually been debated quite a bit — whether using tables for a form is considered semantically correct usage of tables or not. I would suggest you read [url=http://www.codingforums.com/showthread.php?s=&threadid=30718]this thread[/url]; it just may contain the answers you're looking for.
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — I've already been to that link. I've already made a couple of attempts at styling my form using pure css myself, lets just say i didn't come out successful ?

Soo... if someone would maybe help me.... that would be great!

thanks...
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — I find it hard to believe you've been to that exact thread before &#8212; but if you have, great. If you read the entire thing there is a lot of interesting &#8212; and, semantically correct, I might add &#8212; ways of laying out forms. I just don't really understand your problem. Note that, when people say "tables are bad", they are [b]not[/b] referring to using tabular data &#8212; they are referring to incorrect usage of the [font=courier]<table>[/font] element, which is usually using tables for layout. However, it is considered by some that tables are OK for form layout. Although, personally, I do not fully agree, but it isn't as bad as making a layout out of them. You do not have to use CSS for absolutely [i]everything[/i]; think semantically. What element best describes the layout of a form? Probably not tables, but rather using the [font=courier]<label>[/font] element. Another very valid one is to use [url=http://www.w3.org/TR/REC-html40/struct/lists.html#h-10.3]definition lists[/url].
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — I'm sorry you dont believe me that i've seen that thread. But i have. I said i searched the web, i searched the forums, and i've been through that exact post. Sorry to burst your bubble.

And I dont really give a freaking crap about the whole tables VS. css for possitioning forms argument, OKAY.

I personally want to design the layout that is in the link above in my first post, using [b]css[/b].

HOWEVER, I cant, because [b]im too stupid[/b].

So, if you, or someone else, would be kind enough, to try and design the form above, except using css for design, instead of tables, that would be terrific! and if you wont help me, then please stop spamming my thread. Thanks and have a great day!
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — [i]Originally posted by The Cheat [/i]

[B]I'm sorry you dont believe me that i've seen that thread.[/B][/QUOTE]
Now, I never said I didn't &#8212; stop assuming things. I just couldn't believe you have since it such a specific thing. However, if you have, excellent. That should mean you now have more ways of creating a form using semantically correct markup.[i]Originally posted by The Cheat [/i]

[B]And I dont really give a freaking crap about the whole tables VS. css for possitioning forms argument, OKAY.[/B][/QUOTE]
Why the attitude? You asked for help, you got it. This is a free service; we [b]do not need to help you[/b] and you should appreicate all of the help you get. Moreover, the information I provided was completely relevant which it seems you haven't yet realized.[i]Originally posted by The Cheat [/i]

[B]I personally want to design the layout that is in the link above in my first post, using [b]css[/b].[/B][/QUOTE]
I don't think you've fully grasped the concept of using CSS for presentational purposes and structual, semantic markup. While CSS is, indeed, the only way you should style a site, semantic markup is what you should use to structure it. Thus, tables (maybe not), labels, or defintion lists should be used.[i]Originally posted by The Cheat [/i]

[B]stop spamming my thread. [/B][/QUOTE]
I am by no means "spamming your thread". I'm providing accurate and quite correct information and you're simply not understanding what I'm trying to tell you.
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — Why the attitude?[/quote]
I'm sorry... I'm very frusterated with a lot of things right now.. it reflected in my post...

Currently my 768k adsl is going slower than a 56k modem because my isp SUCKS! Plus i'm frusterated because i cant get my form to look the same using css to posistion it. Plus i'm pissed off because i'm not really getting the help that i want.. but you are right i should be thankful for any help i get and i am sorry for that. I was hoping someone could style it using css for me, and leave comments or something so that i then could study what exactly you did and learn by example...

I understand this is free and i completely understand that you do not have to post here and all the help i get i should be very appreciative. I am sorry for being a jerk, it's nothing against you personally..

anyways........ I'd show you the page i made of the form being styled with css .. i got some-what close to what i wanted... but then i got frusterated with it and deleted it completely off my computer..

*sigh* :o

welll....

thats that i guess.
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — No problem man. I can see where you're coming from I suppose. If you need any further help please feel free to ask and I'll attempt to help; if what I'm saying is not making sense to you, prompt me to clarify and I will do so &#8212; even fully-working examples if you'd like.

Have a nice day.
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — i'd love to see a good example of a form that was positioned using css and looks the same as the form i created using tables. That's what im after...

thanks
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — Absolutey. Here's a simple example I just put together in which uses structural, semantically meaningful markup, along with CSS to get it to render the way we want:&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
&lt;title&gt;untitled&lt;/title&gt;
&lt;meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" /&gt;
&lt;style type="text/css"&gt;
/*&lt;![CDATA[*/
label {
display: block;
width: 75px;
float: left;
margin: 2px;
}

<i> </i> div {
<i> </i> margin: 3px;
<i> </i> }
<i> </i> /*]]&gt;*/
<i> </i> &lt;/style&gt;
<i> </i>&lt;/head&gt;
<i> </i>&lt;body&gt;
<i> </i> &lt;form action="#"&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f1"&gt;
<i> </i> Name:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f1" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f2"&gt;
<i> </i> Address:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f2" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f3"&gt;
<i> </i> Gender:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f3" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;input type="submit" value="Submit" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;/form&gt;
<i> </i>&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — Thanks for that! ?

I'm having a problem though... I tried to apply it to my form that i have created, and it wont display properly for some reason.

heres whats happening:

http://www.odna.net/adams/signguestbook2.html

I'm guessing i made a dumb mistake in my markup when adding them, but i've been looking it over forever and cant seem to find what i did wrong...

thanks.
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — You're very welcome. Try this:&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
&lt;title&gt;untitled&lt;/title&gt;
&lt;meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" /&gt;
&lt;style type="text/css"&gt;
/*&lt;![CDATA[*/
label {
display: block;
width: 150px;
float: left;
margin: 2px;
font-weight: bold;
}

<i> </i> div {
<i> </i> margin: 3px;
<i> </i> }

<i> </i> h1 {
<i> </i> text-align: center;
<i> </i> }
<i> </i> /*]]&gt;*/
<i> </i> &lt;/style&gt;
<i> </i>&lt;/head&gt;
<i> </i>&lt;body&gt;
<i> </i> &lt;h1&gt;Sign Guestbook&lt;/h1&gt;
<i> </i> &lt;form action="#"&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f1"&gt;
<i> </i> Name:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f1" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f2"&gt;
<i> </i> E-mail address:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f2" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f3"&gt;
<i> </i> Website &lt;acronym title="Uniform Resource Identifier"&gt;URI&lt;/acronym&gt;:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f3" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f4"&gt;
<i> </i> Comments:
<i> </i> &lt;/label&gt;
<i> </i> &lt;textarea rows="10" cols="50" id="f4"&gt;&lt;/textarea&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;input type="submit" value="Submit" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;/form&gt;
<i> </i>&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — that did the trick. Thanks

Question.

Why do you put

/*<![CDATA[*/

and

/*]]>*/

in the style?
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — It goes there because we are using inline CSS (i.e., it is embedded on the page) and because we are using an XHTML DOCTYPE. The CDATA section is required in case there is certain entities contained inside the [font=courier]<style>[/font] element, primarily [font=courier]<[/font] and [font=courier]>[/font] &#8212; which are not allowed. Thus, the CDATA section, in a sense, allows this and hides it from the validator therefore allowing valid code. You could, however, simply put the CSS in an external file to avoid having to do this. Another option would be to not use an XHTML DOCTYPE (i.e., using an HTML 4.x DOCTYPE), but I'd recommend you just put the CSS in an external file.
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — gotchya ?
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — alright, [URL=http://odna.net/adams/signguestbook2.html]heres[/URL] what i've got so far.

How do i center everything, including the submit and reset buttons?

Thanks dude ?

ps. Could you recomend some links where i can learn more about css positioning and using div's and stuff. I'm just recently digging into css.

After using tables for the last few years, this css stuff is kind of confusing. ? (i've already been to through w3schools css tutorials, so no need to recomend that site... I'm going to be going through it again soon anyways though, as i've already forgotten most of it!!! haha :p )

laterz
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — You're very welcome. It'd be done like this:&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
&lt;title&gt;untitled&lt;/title&gt;
&lt;meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" /&gt;
&lt;style type="text/css"&gt;
/*&lt;![CDATA[*/
label {
display: block;
width: 150px;
float: left;
margin: 2px;
font-weight: bold;
}

<i> </i> div {
<i> </i> margin: 3px;
<i> </i> }

<i> </i> h1 {
<i> </i> text-align: center;
<i> </i> }

<i> </i> form {
<i> </i> margin: 0 auto;
<i> </i> width: 60%;
<i> </i> }

<i> </i> #btn {
<i> </i> text-align: center;
<i> </i> }
<i> </i> /*]]&gt;*/
<i> </i> &lt;/style&gt;
<i> </i>&lt;/head&gt;
<i> </i>&lt;body&gt;
<i> </i> &lt;h1&gt;Sign Guestbook&lt;/h1&gt;
<i> </i> &lt;form action="#"&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f1"&gt;
<i> </i> Name:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f1" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f2"&gt;
<i> </i> E-mail address:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f2" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f3"&gt;
<i> </i> Website &lt;acronym title="Uniform Resource Identifier"&gt;URI&lt;/acronym&gt;:
<i> </i> &lt;/label&gt;
<i> </i> &lt;input type="text" id="f3" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div&gt;
<i> </i> &lt;label for="f4"&gt;
<i> </i> Comments:
<i> </i> &lt;/label&gt;
<i> </i> &lt;textarea rows="10" cols="50" id="f4"&gt;&lt;/textarea&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;div id="btn"&gt;
<i> </i> &lt;input type="submit" value="Submit" /&gt;
<i> </i> &lt;input type="reset" value="Reset" /&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;/div&gt;
<i> </i> &lt;/form&gt;
<i> </i>&lt;/body&gt;
&lt;/html&gt;
For a list of great resources, check my post [url=http://forums.webdeveloper.com/showthread.php?s=&threadid=24366#post126749]here[/url]. Those sites contain more than enough information &#8212; you'll be using CSS and semantically correct markup in no time. Also note, an excellent way to learn is to view people's source &#8212; see something you think is cool? View the source and find out how it was put together. What better way to learn than by example? ?
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — thanks so much! [URL=http://odna.net/adams/signguestbook2.html]this[/URL] works great!

Ok 1 last thing, How do i get name, email, website, and comments to align right against the inputs, like my page using [URL=http://odna.net/adams/signguestbook.html]tables[/URL] does?
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — No problem. That's very simple; all you'd need to do is add one more rule to your CSS:label {
display: block;
width: 150px;
float: left;
margin: 2px;
font-weight: bold;
[b][color=blue]text-align: right;[/color][/b]
}
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — aiight, you rock ?

thanks for helping me and being patient with me.

I'm going to go check out all those links now ?
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — You're really quite welcome. Good luck with everything. ?
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — hey i just realised that when i view it in a resolution lower than 1024x768 or when the window is not fully maximized, the Comments: appears above the comments text area. Is there any way i can fix this?
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — I would suggest increasing the [font=courier]width[/font] property in the [font=courier]label[/font] selector. Insuficent width is likely to be what's causing that.
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — changing the width property in label didn't help, however, i tried changing the width from in the form properties from 60% to 70% and that has done the trick. ?

Hey while you are here, quick question.

normally when i save my html files, i save them as ANSI and DOS (CR+LF) under the format options, and then i use the meta tag <meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />

this is the correct way to do this, right?

or should i be using utf-8 ... or does it even matter?
Copy linkTweet thisAlerts:
@fredmvFeb 05.2004 — [i]Originally posted by The Cheat [/i]

[B]i tried changing the width from in the form properties from 60% to 70% and that has done the trick.[/B][/QUOTE]
See? You're catching on quickly. Nice work. ?[i]Originally posted by The Cheat [/i]

[B]or should i be using utf-8 ... or does it even matter?[/B][/QUOTE]
I don't believe you should have problems either way, but I may be wrong. It really shouldn't make much of a difference, if any.
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 05.2004 — teehee ?
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 06.2004 — hey...

I just now realised that the form looks pretty funky and isn't even centered in internet explorer 5.5... Whats up with that.. ?
Copy linkTweet thisAlerts:
@fredmvFeb 06.2004 — [i]Originally posted by The Cheat [/i]

[B] Whats up with that.. [/B][/QUOTE]
It's because IE sucks &#8212; this is more so true with the older versions. There isn't really much you can do. However, to center it you can use [font=courier]text-align: center[/font]. This should not work, but does since IE allows you to center block-level elements using [font=courier]text-align[/font], while it should only work on inline-level elements.
Copy linkTweet thisAlerts:
@The_CheatauthorFeb 06.2004 — alright... well thats a bummer...
×

Success!

Help @The_Cheat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...