Solved

CSS Text Justification

Posted on 2008-10-25
5
763 Views
Last Modified: 2012-05-05
Hello,

Can anyone comment on why the text-align justify part below does not work ?

thanks,

GISVPN
the CSS ...
 
.article_txt{
font-family: Trebuchet MS;
font-size: 14px;
line-height: 15pt;
text-align: justify;
}
 
 
the HTML ...
 
<td width="365"><span class="article_txt">Some TEXT in a CELL</span</td>

Open in new window

0
Comment
Question by:gisvpn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
jgmontgo earned 250 total points
ID: 22803411
There are a couple of reasons that this is not working:
  • </span should be </span>
  • If the text is shorter than a full line it is not justified, if it is longer it is justified
  • the class needs to be moved to the <td> then the span can be removed
  • The CSS also had a font name that should be in quotes although this is not a serious issue
I have attached a working sample:

@charset "utf-8";
/* CSS Document */
 
.article_txt{
font-family: "Trebuchet MS";
font-size: 14px;
line-height: 15pt;
text-align: justify;
}
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/test.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="365" border="0">
  <tr>
    <td width="365" class="article_txt">Some TEXT in a CELL that is now longer than it used to be but this is really just a testto see what happens when you place more text in the box</td>
  </tr>
</table>
</body>
</html>

Open in new window

0
 

Author Comment

by:gisvpn
ID: 22803695
Great thanks for the info....


</span should be </span> ... sorry my typing error in the post, the original was </span>..

If the text is shorter than a full line it is not justified, if it is longer it is justified ... sorry again, the post just had example text in it, the original had lots of text.

 
the class needs to be moved to the <td> then the span can be removed ... that was the problem ! Moving to the TD made it work. Why did the SPAN method not work ?


The CSS also had a font name that should be in quotes although this is not a serious issue - fixed thanks..
0
 
LVL 42

Expert Comment

by:David S.
ID: 22804137
0
 

Author Closing Comment

by:gisvpn
ID: 31509938
Great thanks for the information. Much appreciated.
0
 
LVL 11

Expert Comment

by:jgmontgo
ID: 22805022
Kravimir is right that "It did not work with the <span> because the <span> is an inline element." If you find the actual usage of text-align: justify it is actually designed to work inside a table. The basic idea is that you have to have a constrained area with a defined right and lest side in order to justify, otherwise the browser would have no idea what to justify against.
Thanks for the points.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question