Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Text aligning

Reply
Thread Tools

Text aligning

 
 
tshad
Guest
Posts: n/a
 
      05-27-2005
I am curious as to why HTML doesn't line up the objects in a cell the way
you ask. Each object seems to be dependant on the other.

For example, in the following code:
************************************************** ******************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 transitional//EN">
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body id="myBody">
<form name="addForm" method="post" action="resumeSubmit.aspx" id="addForm">
<table width="612" border="1" >
<tr>
<td style="vertical-align:top" nowrap>&nbsp;
Resume Title: <input name="ResumeTitle" type="text" value="DataBase
Administrator 3" size="45" id="ResumeTitle" />
</td>
</tr>
</table>
</form>
</body>
</html>
************************************************** *****************

The way this seems to work is that the text is always in the middle of the
textbox. So the textbox goes to the top and the text will still be at the
middle of the textbox. If you delete the textbox, the text moves to the top
of the cell.

If you have an image, the bottom of the image will be at the bottom of the
text (which puts the text at the bottom of the image). The if there is a
text box, that will be a little bit lower (as the text is always at the
middle of the textbox).

Now you can change the valign (or vertical-align) to (top, bottom middle,
baseline etc) and all will move as one. If you say top, the image will go
to the top of the box and all the other objects will be in relation to the
image (as specified before). If you say valign="Bottom", the textbox will
go to the bottom (as it is the lowest object) and everything will move in
relation to that.

The problem is I want to put all all the objects in the middle so that the
text will be in the middle (but next to) the image and the text box at the
middle of the text box.

Is there anyway to do this without putting each in their own cell?

This is actually part of a data table where I want to put text and an image
as well as a text box for editing the data.

Thanks,

Tom


 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      05-27-2005
tshad wrote:

> I am curious as to why HTML doesn't line up the objects in a cell the way
> you ask. Each object seems to be dependant on the other.
>
> For example, in the following code:
> ************************************************** ******************
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 transitional//EN">


4.01 Transitional Doctype with no URL. This will trigger Quirks mode in many
browsers.

> <td style="vertical-align:top" nowrap>&nbsp;


Rather pointless non-breaking space there.

> Resume Title: <input name="ResumeTitle" type="text" value="DataBase
> Administrator 3" size="45" id="ResumeTitle" />


Weird mix of XHTML and HTML style syntax here.

> The way this seems to work is that the text is always in the middle of the
> textbox. So the textbox goes to the top and the text will still be at the
> middle of the textbox. If you delete the textbox, the text moves to the
> top of the cell.


The text and the input are set out in a line. That line is an anonymous
inline box. It is that box which is aligned to the top of the cell.

The trick is to apply the vertical-align property to the input and position
it on the line (in that anonymous inline block).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aligning text =?Utf-8?B?Sm9l?= ASP .Net 2 01-25-2006 07:35 PM
aligning text with space-normalized text Steven Bethard Python 6 07-01-2005 05:38 PM
Aligning text within a JTextArea Phillip Java 2 01-23-2004 04:03 PM
Re: aligning text in a asp label Onur Bozkurt ASP .Net 0 07-25-2003 09:39 AM
IE/Netscape question: aligning text BGW HTML 3 07-08-2003 07:46 PM



Advertisments