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?
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 .
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.
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.
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.
<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.
My solution:
<span style="text-align: justify; display:block;">Your Text</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With