473,473 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Replacing a 2 column table with CSS

Hi all,

I have a form that contains a 2 column table. In the left column is the
description for a particular input (ie - "First Name", "Last Name", "Phone
Number", etc.). In the right column is the input element. The left column
is right aligned and the right column is left aligned. I would like to
replace this table with code that does not use a table for layout, and was
hoping someone might be able to help me with the HTML and corresponding CSS.
My thoughts are that the HTML will be something like this:

<form action="formhandler.asp" method="post">
<div>
<span class="inputdesc">First Name:</span>
<span class="forminput"><input type="text" name="firstname" size="20"
maxlength="50"></span>
</div>
<div>
<span class="inputdesc">Last Name:</span>
<span class="forminput"><input type="text" name="lastname" size="20"
maxlength="50"></span>
</div>
...
</form>

Note that I want all of the "inputdesc" items to be right aligned, and all
of the "forminput" items to be left aligned. Oddly enough, this looks very
"table-ish". :)

Any input (regarding the HTML above and what the CSS will need to look like)
is greatly appreciated.

Regards,
Peter Foti
Jul 20 '05 #1
11 5125
Peter Foti wrote:

I have a form that contains a 2 column table. In the left column
is the description for a particular input (ie - "First Name", "Last
Name", "Phone Number", etc.). In the right column is the input
element. The left column is right aligned and the right column is
left aligned. I would like to replace this table with code that
does not use a table for layout,
Note that one could make the case that this is tabular data, and
belongs in a table. I decided not to use table markup for my forms, fwiw.
was hoping someone might be able to help me with the HTML and
corresponding CSS. My thoughts are that the HTML will be something
like this:

<form action="formhandler.asp" method="post"> <div> <span
class="inputdesc">First Name:</span>
Use the label element instead of the semantically neutral span element.
<span class="forminput"><input type="text" name="firstname"
size="20" maxlength="50"></span>
You don't need a span here. Just the input, ma'am.
Note that I want all of the "inputdesc" items to be right aligned,
and all of the "forminput" items to be left aligned. Oddly enough,
this looks very "table-ish". :)
Indeed. See above.
Any input (regarding the HTML above and what the CSS will need to
look like) is greatly appreciated.


an example of a form I did:

http://www.julietremblay.com/site/contact.html

--
Brian
follow the directions in my address to email me

Jul 20 '05 #2
"Brian" <us*****@mangymutt.com.invalid-remove-this-part> wrote in message
news:GZyjb.572821$cF.246886@rwcrnsc53...
Peter Foti wrote:

I have a form that contains a 2 column table. In the left column
is the description for a particular input (ie - "First Name", "Last
Name", "Phone Number", etc.). In the right column is the input
element. The left column is right aligned and the right column is
left aligned. I would like to replace this table with code that
does not use a table for layout,
Note that one could make the case that this is tabular data, and
belongs in a table. I decided not to use table markup for my forms, fwiw.


I did consider that possibility, but I felt that too much of what I was
doing was presentational (aligning the columns, for instance... and I may
want to add more presentation once the initial design is done).
was hoping someone might be able to help me with the HTML and
corresponding CSS. My thoughts are that the HTML will be something
like this:

<form action="formhandler.asp" method="post"> <div> <span
class="inputdesc">First Name:</span>
Use the label element instead of the semantically neutral span element.


Ah, yes. Almost forgot about that. :)
<span class="forminput"><input type="text" name="firstname"
size="20" maxlength="50"></span>
You don't need a span here. Just the input, ma'am.


Actually, with both the "inputdesc" span and the "forminput" spans I was
trying to keep all of the positioning information separate from the elements
themselves. It's a little redundant, I know. Not sure yet whether I want
to keep 'em or dump 'em. :)
Note that I want all of the "inputdesc" items to be right aligned,
and all of the "forminput" items to be left aligned. Oddly enough,
this looks very "table-ish". :)


Indeed. See above.
Any input (regarding the HTML above and what the CSS will need to
look like) is greatly appreciated.


an example of a form I did:

http://www.julietremblay.com/site/contact.html


Thanks. I'm sure this will prove useful. :)
Regards,
Peter Foti
Jul 20 '05 #3
In article <vo************@corp.supernews.com>,
"Peter Foti" <pe****@systolicnetworks.com> wrote:
http://www.julietremblay.com/site/contact.html


Thanks. I'm sure this will prove useful. :)


One of mine, if you're in for variation:
<http://www.joukedevries.nl/contact/>

--
Kris
kr*******@xs4all.netherlands (nl)
"We called him Tortoise because he taught us" said the Mock Turtle.
Jul 20 '05 #4
"Kris" <kr*******@xs4all.netherlands> wrote in message
news:kr*****************************@news1.news.xs 4all.nl...
In article <vo************@corp.supernews.com>,
"Peter Foti" <pe****@systolicnetworks.com> wrote:
http://www.julietremblay.com/site/contact.html


Thanks. I'm sure this will prove useful. :)


One of mine, if you're in for variation:
<http://www.joukedevries.nl/contact/>


The more the merrier. :)
Thanks,
Peter
Jul 20 '05 #5
Peter Foti wrote:

Note that one could make the case that this is tabular data, and
belongs in a table.
I did consider that possibility, but I felt that too much of what I
was doing was presentational (aligning the columns, for instance...

There is absolutely nothing wrong with styling a table to enhance the
presentation of tabular data. Indeed, it seems like a good idea in
most cases.
and I may want to add more presentation once the initial design is
done).


Well, if you think you'll be fighting against the default display of a
table, then your choice is reasonable.
<span class="forminput"><input type="text" name="firstname"
size="20" maxlength="50"></span>


You don't need a span here. Just the input, ma'am.


Actually, with both the "inputdesc" span and the "forminput" spans
I was trying to keep all of the positioning information separate
from the elements themselves. It's a little redundant, I know.
Not sure yet whether I want to keep 'em or dump 'em. :)


Use <input class="forminput"> instead of <span class="forminput"><input>

Or better still, add some self-documentation to the code:
<form class="catalogue">
<label><input type="text">
in css:
form.catalogue input {}

--
Brian
follow the directions in my address to email me

Jul 20 '05 #6
In article <vo************@corp.supernews.com> in
comp.infosystems.www.authoring.stylesheets, Peter Foti
<pe****@systolicnetworks.com> wrote:
I have a form that contains a 2 column table. In the left column is the
description for a particular input (ie - "First Name", "Last Name", "Phone
Number", etc.). In the right column is the input element. The left column
is right aligned and the right column is left aligned. I would like to
replace this table with code that does not use a table for layout,


It's your choice of course, but IMHO what you have _is_ a table and
<table> markup is appropriate. The descriptions are <th> elements
and the input elements are <td>.

Do you see any particular benefit in changing this to CSS? I think
the result (even without counting the separate style sheet) will be
longer than the original.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #7
Stan Brown wrote:
Peter Foti <pe****@systolicnetworks.com> wrote:
I have a form that contains a 2 column table.

I would like to replace this table with code that does not use a
table for layout
IMHO what you have _is_ a table and <table> markup is appropriate.

Do you see any particular benefit in changing this to CSS?


It's reasonable to want to change the appearance such that a table is
impractical, e.g., by having the city, state, and zip code appear all
on 1 line when filling out a mailing address.[1] In that case, one
might want to use markup other than a table. I chose to use div,
label, and input for forms on a couple of sites I did.
I think the result (even without counting the separate style sheet)
will be longer than the original


The code may be longer on my site, but not by anything remotely
significant. Mind you, I never did change the layout as I had planned.
It is still in 2 columns, a bit like a table. Some day.

[1] That is not appropriate for all forms, of course. City/state/zip
is the way to address an envelop in the U.S., and thus would be
appropriate if the form were requesting a U.S. shipping address.

--
Brian
follow the directions in my address to email me

Jul 20 '05 #8
Peter Foti wrote:
"Kris" <kr*******@xs4all.netherlands> wrote in message
news:kr*****************************@news1.news.xs 4all.nl...
In article <vo************@corp.supernews.com>,
"Peter Foti" <pe****@systolicnetworks.com> wrote:
http://www.julietremblay.com/site/contact.html

Thanks. I'm sure this will prove useful. :)


One of mine, if you're in for variation:
<http://www.joukedevries.nl/contact/>


The more the merrier. :)


here you go then: http://www.williamtasso.com/contact.asp
--
William Tasso
Jul 20 '05 #9
"Stan Brown" <th************@fastmail.fm> wrote in message
news:MP************************@news.odyssey.net.. .
In article <vo************@corp.supernews.com> in
comp.infosystems.www.authoring.stylesheets, Peter Foti
<pe****@systolicnetworks.com> wrote:
I have a form that contains a 2 column table. In the left column is the
description for a particular input (ie - "First Name", "Last Name", "PhoneNumber", etc.). In the right column is the input element. The left columnis right aligned and the right column is left aligned. I would like to
replace this table with code that does not use a table for layout,


It's your choice of course, but IMHO what you have _is_ a table and
<table> markup is appropriate. The descriptions are <th> elements
and the input elements are <td>.

Do you see any particular benefit in changing this to CSS? I think
the result (even without counting the separate style sheet) will be
longer than the original.


There was one case that caused me to question whether this was table data or
not. It's very similar to the example Brian gave. I want to have a single
line that contains 2 pieces of data. In my case, it's a "Work phone number"
and "Extension number". It did not seem appropriate to have something like
this:

<tr>
<td>Work Phone Number</td>
<td><input> Extension Number <input></td>
</tr>

However, if I view this as non-table data, it seems more acceptable.

-Peter
Jul 20 '05 #10
Peter Foti wrote:

<form action="formhandler.asp" method="post">
<div>
<span class="inputdesc">First Name:</span>
<span class="forminput"><input type="text" name="firstname" size="20"
maxlength="50"></span>
</div>
<div>
<span class="inputdesc">Last Name:</span>
<span class="forminput"><input type="text" name="lastname" size="20"
maxlength="50"></span>
</div>
...
</form>

Note that I want all of the "inputdesc" items to be right aligned, and all
of the "forminput" items to be left aligned. Oddly enough, this looks very
"table-ish". :)

Any input (regarding the HTML above and what the CSS will need to look like)
is greatly appreciated.


Your sample is almost identical to the following:

http://www.realworldstyle.com/forms.html

Personally one of the things I really like about going the CSS route
over the table route was that if in the example you change:

div.row span.label {float: left; text-align: right;}
div.row span.formw {float: right; text-align: left;}

to:

div.row span.label, div.row span.formw {display: block;}

then you easily have all your forms switch to another common
presentation format being:

<text1>
<form element1>

<text2>
<form element2>

I guess what I really liked about this implementation was seeing the
real power of CSS in a real world case i.e. we hear about how you should
mark things up properly and then use CSS to affect its presentation well
this IMO is a great example to that effect (outside CSS layouts and the
CSS zen garden samples that is).

Of course if you always used this latter format then you may want to
eliminate the extra CSS but it is sure nice to show a client one format
and if they don't like it change two lines and presto all their forms
alter to another common format. On our site we use the latter format
but who knows we may switch to the former (again) and thus I can focus
on other things now and easily change my mind later if I choose without
re-working numerous form pages.... I doubt the same can said about a
tables implementation ;-)

--Nikolaos

Jul 20 '05 #11
This is one way:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
form {
border: dashed #0074B0;
border-width: 1px 0;
padding: 1em 0;
margin: 0 1em
}
..formrow {
clear: both;
padding: .25em
}
..fieldset {
margin: 0 0 2em 0;
padding: 1em .5em .5em .5em;
border: 1px solid #000000;
}
..legend {
padding: .2em;
background-color: #EBEBFF;
font-weight: bold;
color: #000000;
border: 1px solid #000000;
}
..input {
border: 1px solid #000000;
font-weight: bold;
background-color: #F5F5F5;
}
..accesskey { text-decoration: underline }
-->
</style>
</head>
<body>

<form method="post" action="whatever">
<label for="fname">First Name</label>
<input type="text" id="fname" name="fname" size="12">

<br />
<br />

<fieldset>
<legend accesskey="I">Contact Information</legend>
<label for="name" accesskey="N">Name:</label>
<input type="text" name="name" id="name">
</fieldset>
</form>
</body>
</html>

Regards

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vo************@corp.supernews.com...
Hi all,

I have a form that contains a 2 column table. In the left column is the
description for a particular input (ie - "First Name", "Last Name", "Phone
Number", etc.). In the right column is the input element. The left column is right aligned and the right column is left aligned. I would like to
replace this table with code that does not use a table for layout, and was
hoping someone might be able to help me with the HTML and corresponding CSS. My thoughts are that the HTML will be something like this:

<form action="formhandler.asp" method="post">
<div>
<span class="inputdesc">First Name:</span>
<span class="forminput"><input type="text" name="firstname" size="20" maxlength="50"></span>
</div>
<div>
<span class="inputdesc">Last Name:</span>
<span class="forminput"><input type="text" name="lastname" size="20"
maxlength="50"></span>
</div>
...
</form>

Note that I want all of the "inputdesc" items to be right aligned, and all
of the "forminput" items to be left aligned. Oddly enough, this looks very "table-ish". :)

Any input (regarding the HTML above and what the CSS will need to look like) is greatly appreciated.

Regards,
Peter Foti

Jul 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dmitri Shvetsov | last post by:
Hi, Is it possible to do from one script? We have a set of user's tables like "tbl%". We can get this list very easy using this script: SELECT name FROM sysobjects WHERE xtype = 'U' AND name...
7
by: Wilhelm Kutting | last post by:
Hi again i want to replace the following layouttabel with css/xhtml: ---------------------------------- <table width="640" cellspacing="0"> <tr> <td valign="top">My Title</td> <td...
3
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
16
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables...
3
by: Coleen | last post by:
Hi all :-) I have a datatable that I need to clone completely except for 1 column - I need to replace the contents of this 1 column with the contents from another datatable that has the exact...
13
by: Kun | last post by:
I have a python-cgi file that pulls data from an sql database, i am wondering what is the easiest way to remove all instances of '00:00:00.00' in my date column. how would i write a python...
2
by: BF | last post by:
Hi, I have some tables where I import data in, lots of field have gotten a NULL value which the application can not handle. Now can I replace each NULL value with '' in a columns with: update...
1
by: cma6 | last post by:
I have a page which uses tables for layout http://www.vintagetextile.com/1920s_to_1930s.htm The checkerboard pattern is achieved with this markup: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML...
1
by: =?ISO-8859-1?Q?S=F8ren?= | last post by:
Hi guys I got the following code: ------------------------------------------------------- Dim Word As New Microsoft.Office.Interop.Word.Application Dim Document As...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.