Jump to content
xisto Community
Sign in to follow this  
Dagoth Nereviar

Is It Possible To Align Text To The Center And Justify It? Example inside

Recommended Posts

Basically, I have a list (like shown below) but as you can see, some parts stick out more than others, and it doesn't look ordered.

 

What I wish to know is if it's possible to justify the text so it's ordered, but also keep it in the centre, using CSS :( Although if another coding language needs to be used, then that's ok :P

 

Example:

Beginning with A

Beginning with O

Beginning with V

Beginning with W

Beginning with I

Beginning with M

Beginning with P


(Random letters to show how I mean easier :( without going through the whole alphabet)

 

Thanks to any who reply :(

Edited by Dagoth Nereviar (see edit history)

Share this post


Link to post
Share on other sites

What you mean by "ordered" as in it's not aligned with each other at all? This cannot be possible using just CSS or anything else because the character width of each letters, i.e. A, O, V, W, I, M and P. The simplest way to resolve the alignment issue is to create LETTERS in graphics with all of them having the same width and height. The method you should try is to align "Beginning with" and let LETTERS drift offBeginning with ABeginning with OBeginning with VBeginning with WBeginning with IBeginning with MBeginning with PAnd these would be enclosed within a DIV or TABLE and centered to a page...The complicated way is to use CSS to set LETTERS as the same width with same space apart. But you may end up with 26 different cases to align them all in a line, not to mention they may not look all the same (some wider than others).

Share this post


Link to post
Share on other sites

I would put the entire list in a DIV, and set the text alignment within the DIV to justify. This will (obviously) justify the list. Then, if you set the left and right margins of the DIV to auto, then it will centre align the DIV within the parent element. This should give the look of a centre-aligned, justified list. I've tried it and it does work, although you have to fiddle around with the width of the DIV to get the look you want.

Share this post


Link to post
Share on other sites

Is this any better?Adjust the spacing by increasing the margin on the class.


<head> <title>An XHTML 1.0 Strict standard template</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link type="text/css" rel="stylesheet" href="./w3c_suggested.css" media="all" /></head><style type="text/css">.box { margin: 0; padding: 0em; }.centre { margin: 0 2em; text-align: center; }</style><body> <div class="box"><p class="box" >Beginning<span class="centre">with</span> A</p><p class="box" >Beginning<span class="centre">with</span> C</p><p class="box" >Beginning<span class="centre">with</span> V</p><p class="box" >Beginning<span class="centre">with</span>W</p><p class="box" >Beginning<span class="centre">with</span>  I</p><p class="box" >Beginning<span class="centre">with</span> M</p><p class="box" >Beginning<span class="centre">with</span> P</p></div></body></html>

I placed a "non-breaking space" in the narrow glyphs and two in the "I". No adjustment to the 'W'. Might work?


Share this post


Link to post
Share on other sites

Thank you for all the replies :PMy idea was to use a div, and then a table to align it, which looks like I will have to do.I'll have to have the heading in a different div too, or else it won't work, right?

Share this post


Link to post
Share on other sites

Just a reminder that tables do, in fact, have their uses, although it would appear that you are using the table in a structural way to format the data and that is not what tables are designed for. Using a table for this task is not "semantic" and alternatives should be considered.

Share this post


Link to post
Share on other sites
Tonus Maximus SuronimousIs It Possible To Align Text To The Center And Justify It?

This is a reply to a very old post, I doubt it will still interest Dagoth Nerevia, but here it is for the G00glers:

<HTML>

<STYLE>

p  { font-family: sans serif; font-size: 0.875em; margin-left: 30% ; }

</STYLE>

<p>Beginning with A</p>

<p>Beginning with O</p>

<p>Beginning with V</p>

<p>etc, etc, </p>

</HTML>

(The key to this is : "margin-left: 30%;". The "30%" can be whatever.)

Hope this helps somebody in the years to come...

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.