简体   繁体   中英

alternative of text-justify:newspaper html

I have a paragraph, which is text-align:justify . But due to some words the difference between words increase so much. There was a property text-justify:newspaper; which breaks the words to make them relevantly spaced. But it is not supported by any browser except IE. Is there any alternative for this property.

Or what is the best way to justify them.

Fiddle Here

In your case, the best way would be to keep text-align:left; by applying a fixed width (either in percentage or pixels) to achieve what you are looking for.

For Instance,

element.style {
    text-align: left;
    width: 220px;
}

Fiddle Demo

Hope this helps.

PS: width: 220px; is an illustrative value. You can change it as per your scenario.

HTML :

    <div class="pad1" style="width:190px;">
        <h2 class="center">Why are</h2>
        <p style="word-spacing: 2px;">Our work process includes the smooth communication between the client and the  execution team As soon as we receive a project <b>request, it is</b> immediately registered in the system and a project code is assigned to it. </p>
        <div class="wrapper center">
            <a class="button" href="users/About#why"><span><span><font style="margin-top:1px;"><cufon class="cufon cufon-canvas" alt="More" style="width: 51px; height: 20px;"><canvas width="63" height="25" style="width: 63px; height: 25px; top: -3px; left: -1px;"></canvas><cufontext>More</cufontext></cufon></font></span></span></a>
        </div>
   </div>

I thik u can use only word-spacing: 2px; instead of text-align: justify; text-justify: newspaper; text-align: justify; text-justify: newspaper;

The text-justify: newspaper setting does not break words; instead, it adds spacing between letters of a word when justification is needed. Browsers that do not support it (all but IE) do not provide any way to affect the justification process: justification causes spacing between words to be added, and that's it.

However, you can usually get much better justified text if you make browsers hyphenate words. This reduces the need for added spacing. There are several ways to do hyphenation, but nowadays the approach that works most widely is JavaScript-based hyphenation client-side, using eg Hyphenator.js .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM