Link to home
Start Free TrialLog in
Avatar of quickbasic
quickbasic

asked on

Aligning text..

Hi there,

Can anyone tell me how i can do this ? I want the text on a html page to be aligned on both the left and right side. How can i do this without using any script ? (Preferable html code)
Avatar of MasseyM
MasseyM

Do you mean that you want the text to span the entire page?

Not sure what you are asking to do...

You aren't looking for something like this are you?
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="LEFT">I am Left Aligned</TD>
<TD ALIGN="RIGHT">I am Right Aligned</TD>
</TR>
</TABLE>
<P align="justify">
this text will be justified. (Aligned left and right)
</P>
Try that in Netscape :)

Heck, for matter of fact, try that in Internet Explorer :)

Woops....never tried it in Netscape. I'll take your word that there will be problems.

<Answer withdrawn>
oh yeah....it DOES work in IE 4.
It doesn't work in IE 5
Avatar of Mark Franz
Try this, text-align:
Value: left | right | center | justify
Initial: UA specific
Applies to: block-level elements
Inherited: yes
Percentage values: N/A

This property describes how text is aligned within the element. The actual justification algorithm used is UA and human language dependent.

Example:

DIV.center { text-align: center }
Since 'text-align' inherits, all block-level elements inside the <DIV> element with CLASS=center will be centered. Note that alignments are relative to the width of the element, not the canvas. If 'justify' is not supported, the UA will supply a replacement. Typically, this will be 'left' for western languages.

<... col...>: (IE only)
ALIGN="center|justify|left|right"
This sets the text alignment within the column group. The default value is "center"


Avatar of quickbasic

ASKER

Adjusted points to 60
I thought this would be an easy question. I've added 10 extra points as a bonus to who solves my problem.
Can you elaborate further?  The comments suggested so far are viable solutions, are you using columns?  Is this in a table?  Do you want a few <td> where the left <td> aligns the text left, and the right <td> aligns the text right?
I want the same effect in my browser on the text as in Word when you choose for 'Fill out'. Note, every browser must be able to display it, and i don't want to use any script.
???  What is a 'fill out'?  Are you talking about a form page?
ok, let me try it in words...
I've got a couple of sentences like this
This is a test, this is a test
This is a test, this is a test.

Now i wan't that text to be outputed like this:
This  is  a  test, this  is  a  test
This  is  a  test, this  is  a  test.

So that all sentences take in the same amount of space. Hope this clears up my question.
Can't do it without a script.  Since HTML code recognizes a space as a space only, and &nbsp; as a space, there is no way to control how much space is between words without entering a &nbsp, how are you going to handle browser size issues?

Sorry... I don't know of any way to do this.
Ok, It seems this problem can't be solved I'm going to delete it.
see the text above...
This question has a deletion request Pending
This question no longer is pending deletion
Seems that by providing an answer, we have given you a solution.  Granted bad news is bad news, but it is an answer.
The only way you can get right and left aligning is using the CSS property setted to "justify" for the paragrapgh you refer to or, more simply, use:

<P align="justify">Text to justify</p>

There is no other way to get this feature neither in Netscape nor in Explorer.

Keep in mind, moreover, that this feature is only available with 4.x versions of the browsers.

The justifying has as countepart the inserting of spaces between words (like in Microsoft Word) and this can give results very different depending on font settings on every browser (especially if words of sentences are long).

Sometimes you can have unexpected results in formatting page, again different in Netscape and Explorer.

With combining the use of tables you can format page with more control on layout, but depends on the results you want to have.

Script does not resolve problem, because the layout resides on HTML format, so HTML + CSS are the only way to control layout. Javascript or VBscript can only access page properties through their privileged ways, but cannot change the "rules of the game"

If you really need universal layout controlled, with the "same" output for every browser, the only way is use graphics. Write you text, and then with cut and paste with a good graphic program (like Paint Shop Pro or Corel Photopaint) get your text converted in GIF or JPG format.

Be careful to not exagerate with images, because they are more slow to load. But if you break up your big images with the text formatted in small one (put side by side on the page) you can get good results (see Microsoft and Borland Sites for an example).

The results depends only on your ability.


Good work!

damianosky, the CSS 'justify' solution has been posted here at least three times, if you had read the question and it's comments you would have known that.
Mr. mgfranz, it's quickbasic to decide if my answer is complete or not, NOT you. He has done an answer, i've give him my proposed COMPLETE answer, obviously covering some parts just explained (it is unavoidable).

If he doesn't like it, no problem for me. He can refuse my answer (or simply ignore it).

If YOU have some problems, avoid your awfull comments. This is not the first of yours i find here in E-E; if you are not able to give a good answer, try to not write stupids comments to the answer of others, which are here to help someone, not to win or earn anything.

If you don't agree with expert exchange rules, avoid to come here with your stupid observation.

Thanks!!
"awful comments"?  I stated that your proposed "answer" has been given 3 times previously.  It is avoidable.  If you have some comments that are of importance that has not already been covered then feel free to post them, it's not the rule, just the courtesy to those who have been there prior to your imitation.

If you have a SOLUTION to a posted problem, then feel free to post an answer, otherwise leave it alone.  

In other words, be part of the solution, not the problem.
<Damien>"If you don't agree with expert exchange rules, avoid to come here with your stupid observation."

I don't think it is against EE rules to point out someone else's MISTAKE. However, I do believe that it is VERY improper for you to post other expert's answers as your own. I guess you really want an EE t-shirt but this is not the way to get it.
Damien, You have only been here for a month, please be thoughful when posting comments or answers.  It is improper to use another experts comment as your answer.
Sorry, but it's not the answer I'm looking for. And not all browsers can show it with your answer.
ASKER CERTIFIED SOLUTION
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, It isn't possible...I agree