Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Justify text inside span tags

Tags:

css

I have a markup like this

<div><span>My name is</span><span>ABC</span></div>

How can I justify this text on the whole line?

like image 225
Anant Avatar asked Mar 02 '10 06:03

Anant


People also ask

How do you align text in a span tag?

Text Align To center an inline element like a link or a span or an img, all you need is text-align: center . For multiple inline elements, the process is similar. It's possible by using text-align: center .

How do you justify text in HTML tag?

The align attribute of <p> tag is used to justify the text on a web page. This can be done by assigning the value to the aligned attribute as justified.

Which tag we can use inside span?

The <span> tag is an inline container used to mark up a part of a text, or a part of a document. The <span> tag is easily styled by CSS or manipulated with JavaScript using the class or id attribute. The <span> tag is much like the <div> element, but <div> is a block-level element and <span> is an inline element.

How do I justify text in a div?

Thus, to justify a paragraph, you could use the <p align="justify"> markup. To justify a larger part of a document, such as several consecutive paragraphs, you might slap <div align="justify"> and </div> around the part.


2 Answers

<div style="text-align: justify"><span>My name is</span><span>ABC</span></div>

Pretty simple, the spans will not break the text justification. If text is only one line long, it is not possible to justify it across the entire line. As well, the last line of a paragraph cannot be justified across the entire line either.

like image 69
animuson Avatar answered Sep 22 '22 14:09

animuson


My solution:

<span style="text-align: justify; display:block;">Your Text</span>
like image 33
Marc Juchli Avatar answered Sep 23 '22 14:09

Marc Juchli