0

We all know that if an img in HTML cannot be loaded, the alt text will be rendered instead. What if I want the alt be, say, a div? Maybe some JavaScript will help?

1 Answers1

1

You can use the alt tag within a DIV but that wouldn't be valid HTML or HTML5.

W3 Validator

Attribute alt not allowed on element div at this point.

You can however use title in HTML4/5 or data- in HTML5 with in DIV and other elements. The rest of your question is not clear and I recommend you edit it before people vote closure on it, also the question may become more suitable on Stack Overflow so please do ensure that you check their for similar questions and answers.

Simon Hayter
  • 32,999
  • 7
  • 59
  • 119
  • 2
    I think one of us has misunderstood the question. I thought the question is asking about how if an image can't be loaded, the alt tag is shown, but instead of the plain text of the alt tag, is it possible to show an entire div instead? – grg Sep 10 '15 at 18:55
  • 1
    Who knows, the way its written is hard to tell... – Simon Hayter Sep 10 '15 at 19:21