Jul 25, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > CSS (Cascading Style Sheets)

free web hosting

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

Dagoth Nereviar
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 tongue.gif Although if another coding language needs to be used, then that's ok smile.gif

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 tongue.gif without going through the whole alphabet)

Thanks to any who reply biggrin.gif

 

 

 


Reply

BuffaloHELP
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 off

Beginning with A
Beginning with O
Beginning with V
Beginning with W
Beginning with I
Beginning with M
Beginning with P

And 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).

Reply

kraizii88z
The only thing i could think of would be to justify a table and center it.

Reply

rvalkass
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.

Reply

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

CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<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>&nbsp;A</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;C</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;V</p>
<p class="box" >Beginning<span class="centre">with</span>W</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;&nbsp;I</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;M</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;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?

 

 

 


Reply

Dagoth Nereviar
Thank you for all the replies biggrin.gif

My 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?

Reply

jlhaslip
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. text alignment codes around pics - 14.48 hr back. (1)
  2. text-align center-justify - 168.10 hr back. (2)
Similar Topics

Keywords : align, text, center, justify, inside

  1. Text Size Problem
    (6)
  2. Align Text Column Without Tables Using Css
    Is it possible to get a 3 column alignment without using tables with C (13)
    I know I can use tables to get this effect but I am not sure if CSS can do it. I have not found any
    examples so far, the only alignments with CSS I have come across are whole div elements and nothing
    for inside formatting like tables offer. Heres my current stage of my layout so far. select a
    character to see output. http://sonesay.trap17.com/chars.php
    http://sonesay.trap17.com/profile.css The attached file is of my original plan but at this stage
    I cannot do a php+ajax pagination for characters because of lack of knowledge so I went with the
    simple drop down lis....
  3. Need Help On "global News" Problem.
    Change paragraph of text with CSS style change? (7)
    I am making a website for my IT Support class and a program called "Cox Connects Kids" for my
    mid-term assignment. Now I have the whole layout made and I will post a screen shot down lower. My
    basic problem/question is this: I have a right section of the page(A div) and it is supposed to be
    a global news part that shows the same on every page(I.e. home,contacts,help) and I was wondering if
    I can somehow edit my CSS file to have it in there and just change it the one time for all the
    pages. I am guessing there is some way to do this but I couldn't figure it out. I....
  4. How Can I Indent Text A Specified Amount
    (every line, not just the first) (4)
    Hey all I'm working on several pages in HTML using external CSS formatting and i need a table
    for navigation along the left hand side with links in it and i want the text to sit next to this
    table to the right the entire length of the page even though the table will end, probably about half
    way down. eg: QUOTE ____ ____| text text text ____| text text text ____| text text text ____|
    text text text ------text text text ------text text text (the "-"'s are to add spacing as i
    cant use multiple spaces. See how the text stays in line and doesn't rever....
  5. Css Image Position Problem
    align image left or right (1)
    I am having problems figuring out why my image will not align how I want it. Here , you can see
    that the image is aligned to the left. This is the code for that block: CODE <a
    href="http://img355.imageshack.us/img355/844/r25870774779uu.jpg"><img
    src="http://img355.imageshack.us/img355/844/r25870774779uu.th.jpg" alt="bush
    bathroom break note" align="left" style="margin-right:
    5px;"></a>[text goes here] But if you go here , you can see that the
    text does not stay to the right of....

    1. Looking for align, text, center, justify, inside

Searching Video's for align, text, center, justify, inside
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE