473,586 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

css form element placing, no tables

Hello,
I've got a site project that i've got to design a layout without
resorting to tables. I want to use a table for tabular data not any
formatting layout, primarily emphasis needs to be on using css to place form
elements. My method thus far has been to use a table, for several reasons i
don't want to resort to this, i'd rather place the elements with css and get
a standards compliant site. I am uncertain as to how to accomplish this.
Thanks.
Dave.
Jul 20 '05 #1
12 5898
On Thu, 16 Sep 2004 02:34:52 GMT, "dave" <dm*******@woh. rr.com> wrote:
I've got a site project that i've got to design a layout without
resorting to tables. I want to use a table for tabular data not any
formatting layout, primarily emphasis needs to be on using css to place form
elements. My method thus far has been to use a table, for several reasons i
don't want to resort to this, i'd rather place the elements with css and get
a standards compliant site. I am uncertain as to how to accomplish this.


A much discussed issue. My preference, and that of about half the
regulars here, is to consider that each form element and its
corresponding label are in fact tabular data: the association between
label and element is meaningful, not merely cosmetic.

A representative of the other half will be along shortly to tell you how
you can do it without tables anyway. ;-)

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #2
On Thu, 16 Sep 2004 07:56:15 +0200, Stephen Poley
<sb************ ******@xs4all.n l> wrote:

A representative of the other half will be along shortly to tell you how
you can do it without tables anyway. ;-)


Nah, I won't complain if you do ;)
Jul 20 '05 #3
Stephen Poley <sb************ ******@xs4all.n l> wrote in message news:<4f******* *************** **********@4ax. com>...
A representative of the other half will be along shortly to tell you how
you can do it without tables anyway. ;-)


I do hope so! I was about to ask the same question when this thread
was started. I know the issue has been discussed before, but the only
real solution I could find was to use a table.

If you just take the minimum amount of markup:

<form>
<label for="foo">Your foo:</label><input id="foo" name="foo" ... >
<label for="bar">Your bar:</label><input id="foo" name="foo" ... >
</form>

you could set display:block for the labels, give them a fixed width
(in em of course) and position them either with float:left or with
position: absolute in combination with an appropriate margin for the
rest of the form.

The problem is: Mozilla and Netscape 7 (and possibly other browsers)
don't understand this and don't display the labels at all :( You'll
have to hide these rules from them (how?) or resort to using a table.

<academic>
I think it's not unreasonable to consider label/input pairs to be a
table, but it would be nicer and simpler if you didn't have to use
that roundabout way. To put the question the other way: what does
marking this up as a table actually add in terms of semantics/logic?\
</academic>

Garmt de Vries.
Jul 20 '05 #4
On 16 Sep 2004 05:54:49 -0700, Garmt de Vries <gd*****@hotmai l.com> wrote:
Stephen Poley <sb************ ******@xs4all.n l> wrote in message
news:<4f******* *************** **********@4ax. com>...
A representative of the other half will be along shortly to tell you how
you can do it without tables anyway. ;-)


I do hope so! I was about to ask the same question when this thread
was started. I know the issue has been discussed before, but the only
real solution I could find was to use a table.

If you just take the minimum amount of markup:

<form>
<label for="foo">Your foo:</label><input id="foo" name="foo" ... >
<label for="bar">Your bar:</label><input id="foo" name="foo" ... >
</form>

you could set display:block for the labels, give them a fixed width
(in em of course) and position them either with float:left or with
position: absolute in combination with an appropriate margin for the
rest of the form.

The problem is: Mozilla and Netscape 7 (and possibly other browsers)
don't understand this and don't display the labels at all :( You'll
have to hide these rules from them (how?) or resort to using a table.


This works in Moz.

form div {position: relative; font-size: 100%; line-height: 1.5;}
form div label {display: block; width: 10em; text-align: right;}
form div input {font-size: 100%; position: absolute; top: 0; left: 13em;}
<form>
<div><label for="realname"> Your Name (required):</label><input type="text"
name="realname" id="realname"> </div>
<div><label for="email">Ema il Address (required):</label><input
type="text" name="email" id="email"></div>
</form>
Jul 20 '05 #5
Neal wrote:
This works in Moz.

form div {position: relative; font-size: 100%; line-height: 1.5;}
form div label {display: block; width: 10em; text-align: right;}
form div input {font-size: 100%; position: absolute; top: 0; left: 13em;}
<form>
<div><label for="realname"> Your Name (required):</label><input
type="text" name="realname" id="realname"> </div>
<div><label for="email">Ema il Address (required):</label><input
type="text" name="email" id="email"></div>
</form>


I really like this technique - seems much safer than relying on floats.

One thing occurs - I haven't had a chance to test in anything but
Firefox, but it seems to work there:

form label { display: block; position: relative; }
form label input { position: absolute; left: 24em; }

<form action="">
<label>
Text Input 1
<input type="text" />
</label>
<label>
Text Input with long title
<input type="text" />
</label>
<label>
Text Input 3
<input type="text" />
</label>
</form>

Cuts down on extraneous markup somewhat. Depending on your layout,
setting right: 0 on the inputs might work well too . . .

Just idle conjecturing :)

P
Jul 20 '05 #6
Hello Stephen,
Thanks for your reply. Can you give an example of what your concept is?
Thanks.
Dave.
Jul 20 '05 #7
Phil Evans <ne********@phi lHADDOCKevans.r emovethefish.co m> wrote in message news:<10******* ********@smtp-1.griffin.com>. ..
Neal wrote:
This works in Moz.

form div {position: relative; font-size: 100%; line-height: 1.5;}
form div label {display: block; width: 10em; text-align: right;}
form div input {font-size: 100%; position: absolute; top: 0; left: 13em;}
<form>
<div><label for="realname"> Your Name (required):</label><input
type="text" name="realname" id="realname"> </div>
<div><label for="email">Ema il Address (required):</label><input
type="text" name="email" id="email"></div>
</form>

Oddly enough..
In IE 6 these text field seem to disappear when I reduce my browser
window size. But not to worry they reappear when it is maximized.

huh?
Jul 20 '05 #8
On 17 Sep 2004 17:14:19 -0700, Nairb <bg***@yahoo.co m> wrote:
Oddly enough..
In IE 6 these text field seem to disappear when I reduce my browser
window size. But not to worry they reappear when it is maximized.

huh?


Possibly, resizing the browser after the page has been rendered confuses
IE6.
Jul 20 '05 #9
On Fri, 17 Sep 2004 17:51:49 GMT, "dave" <dm*******@woh. rr.com> wrote:
Thanks for your reply. Can you give an example of what your concept is?


Well *an* example is
http://www.xs4all.nl/~sbpoley/webmatters/contact.html

Though it wasn't actually composed as an example of how to lay out
forms, and I have to admit that a couple of aspects are a bit debatable.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #10

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

Similar topics

19
2975
by: Pete | last post by:
I have form/select which executes a function using onchange. No problem. However, when I validate the page with a strict HTML 4.01 doctype at http://validator.w3.org, it demands either an action or a method for the form?. If I give it an empty action <form action="" ..... it validates OK. Is this acceptable or is there a better/standards...
11
2008
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below should be reproducible with that version at least. BACKGROUND: =========== When you open this page in your browser, you will see a 4 cell table....
8
7149
by: L Major | last post by:
Hi Unfortunately, I am limited to using tables for part of my current project. I have a form that spans across a number of TR and TD in the shape of checkboxes. Doctype is XHTML 1.0 Transitional, Encoding is utf-8 Is there anything wrong? Should I try something else? What in that case?
2
2900
by: Asad | last post by:
I have a form on a page that has several textareas, and textboxes inside a table (so the table containing the textboxes is also inside the FORM tag). I want to replace the textareas with simple text instead. But I want to keep the format of my page EXACTLY the same. However, the problem is that ... 1) Javascript won't let me create say a...
8
3653
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special...
2
2981
by: dBNovice | last post by:
Hi all! I have 3 separate forms: Tasks, Subtasks, and Elements. All 3 is related by TaskId and Subtasks and Elements are related by SubtaskID. In the DB after I add a task, I want to be able to add one or more subtasks and then one or more elements. I need the subtasks and elements to be have the same taskid as the task; also I want the...
11
2982
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the...
4
1975
by: Ronald Raygun | last post by:
I have a form on an HTML page with the usual user name, email etc. I want to be able to display a popup window (callout?) when a text input control element is clicked. For example, for the form: <form action="something.php" method="post"> <label for="uname">User Name</label> <input type="text" id="uname"/> <input type="image"...
1
1470
by: Leo Smith | last post by:
I am trying to get the position of an element, and have it working in all the latest browsers other than IE. I want to get the current position on the page. I am using float Left or Right for placing the elements and this has allowed me to skip using tables to layout the page. The draw back I am having, is simply IE gives me the position me the...
0
7841
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3838
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.