467,163 Members | 976 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,163 developers. It's quick & easy.

span problem

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
  • viewed: 14742
Share:
3 Replies
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
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
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.

Similar topics

1 post views Thread by gadi | last post: by
8 posts views Thread by knoxautoguy | last post: by
2 posts views Thread by reproots@gmail.com | last post: by
4 posts views Thread by coldflame | last post: by
reply views Thread by jesmi | last post: by
2 posts views Thread by Ravi Joshi | last post: by
1 post views Thread by abranches | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.