Forum Moderators: open

Message Too Old, No Replies

Alt Tag text positioning

         

Bomb

11:43 pm on Oct 14, 2004 (gmt 0)

10+ Year Member



Ok, I fairly new to HTML, and I was wondering if it was possible to control the positioning of text within the Alt tag. Lets say I want the tag to center two lines that are sperated.

ALT="LINE ONE
line two">

Shouldn't there be a way to center the two lines correctly, so that they display one on top of the other within the tag?

Thanks for looking. :)

encyclo

12:02 am on Oct 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com], Bomb.

I'm not aware of any way of controlling the display of the text within the

alt
attribute. You need to bear in mind that, in general, white space has no influence in HTML markup.

It is important to note also that you should not rely on the tooltip showing the alt text - modern browsers other than Internet Explorer do not show it at all as a tooltip, and it is meant as an alternative to the image, not a complement to it.

kaled

12:06 am on Oct 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Someone may correct me but I believe that there are no style controls for alt text and only plain text is permitted. However, you could try style="text-align:center" for the <img> - it might work in some browsers.

Kaled.

Cook

12:48 am on Oct 15, 2004 (gmt 0)

10+ Year Member



Also somewhat surprisingly you can break your alt text over several lines by just putting it on several lines directly in your html source.

Html tags like <br /> in alt text do not work and are displayed as is. This indicates that alt text are taken very literally by browsers. Html entities are properly translated however...

I've seen some people achieve some level of centering by just inserting spaces at the beginning of the lines they want centered:

<IMG src="image.gif" alt="This is my first line
and this is
my second line" \>

I would not bet on different browsers handling the above consistently though. I personally stick to plain single-lined alt text, no fancy.

As encyclo mentions, better consider alt as what they're meant to be: just alternate to images when they can't be displayed for some reasons, or for impaired users.

Cheers,
Cook

Cook

1:37 am on Oct 15, 2004 (gmt 0)

10+ Year Member



Oops, ASCII art does not render well here, I should have expected that. Anyway, there should be a few spaces leading the 2nd and 3rd lines of the alt text above...

Cheers,
Cook

Bomb

7:55 am on Oct 15, 2004 (gmt 0)

10+ Year Member



Alright, good stuff to know. I appriciate everyones help answering my question. :-)

You'll continue to see me around these parts, I am sure...

sem4u

8:01 am on Oct 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can try and look into what cook said about adding spaces between the lines, but I don't think it will work in all browsers.

I was trying to do something similar the other day as well.