By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,739 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,739 IT Pros & Developers. It's quick & easy.

span problem

P: n/a
Sorry to bother you; in the below test, <SPAN> doesn't do the text
alignment. What's wrong? Using Opera 7.50 for Windows.

<HTML>
<HEAD>
</HEAD>

<BODY>

<P>regular text
<span style="text-align:center">text-to-center</span>
</p>

<!--
It didn't center the text-to-center
-->

<P style="text-align:center">
text-to-center
</p>

</body>
</HTML>

--
Sheldon Isaac
lose all .control when replying
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Shel <si************@netaccess.control.com> writes:
Sorry to bother you; in the below test, <SPAN> doesn't do the text
alignment. What's wrong? Using Opera 7.50 for Windows.
text-align only applies to block elements - span is not a block element.
<P>regular text
<span style="text-align:center">text-to-center</span>
</p>


Options:
<p>regular text</p>
<p style='text-align: center'>text-to-center</p>

or

<p>regular text
<span style='text-align: center; display: block;'>text-to-center</span>
</p>

depending on whether the text being centred is logically part of that
paragraph (2nd option) or not (1st option, probably more likely in
most cases)

--
Chris
Jul 20 '05 #2

P: n/a
Shel wrote:
Sorry to bother you; in the below test, <SPAN> doesn't do the text
alignment. What's wrong? Using Opera 7.50 for Windows.

<P>regular text
<span style="text-align:center">text-to-center</span>
</p>

<!--
It didn't center the text-to-center
-->


Spans are inline elements, try a block level element like a div.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #3

P: n/a
Chris Morris <c.********@durham.ac.uk> wrote:
text-align only applies to block elements - span is not a block element. <p>regular text</p>
<p style='text-align: center'>text-to-center</p>

or

<p>regular text
<span style='text-align: center; display: block;'>text-to-center</span>
</p>

depending on whether the text being centred is logically part of that
paragraph (2nd option) or not (1st option, probably more likely in
most cases)


Thank you very much!

It was the "first option" situation

--
Sheldon Isaac
lose all .control when replying
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.