Can I use some sort of line break in the alt text for an image while still adhering to the XHTML 1.0 Strict standard?
Something like this...
<img src="foo.jpg" alt="Line 1\nLine 2" />
I'm asking because I want to post the following screenshot on my site, but I want to include the text-only version in the alt text for SEO reasons and for the visually impaired.
I prefer the screenshot over the plain text version because it looks more visually appealing.
To add spacing between lines or paragraphs of text in a cell, use a keyboard shortcut to add a new line. Click the location where you want to break the line. Press ALT+ENTER to insert the line break.
To do a line break in HTML, use the <br> tag. Simply place the tag wherever you want to force a line break. Since an HTML line break is an empty element, there's no closing tag.
Alternative (Alt) Text is meant to convey the “why” of the image as it relates to the content of a document or webpage. It is read aloud to users by screen reader software, and it is indexed by search engines. It also displays on the page if the image fails to load, as in this example of a missing image.
Just use a normal line break.
<img src="foo.jpg" alt="Line 1
Line 2" />
Stack Overflow does this in their titles :)
Then add this CSS:
img{white-space:pre}
Demo: http://jsfiddle.net/Madmartigan/S8SXP/
A better way is to just add the HTML character code for line feed or carriage return.
line feed is 

carriage return 
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