What about elements that don't have a close tag, such as <IMG> and <hr>
XHTML Interview Questions and Answers
(Continued from previous question...)
8. What about elements that don't have a close tag, such as <IMG> and <hr>
There are two solutions. You could use a close tag (e.g. <img src="logo.gif" ...></img>). However the best solution is to simply include a forward slash in the element: <img src="logo.gif" ... />
Will this work?
As long as you include a space before the slash it will cause no problems in most Web browsers - although there have been reports of problems with some embedded HTML viewers such as Java's Swing HTML editor.
(Continued on next question...)
Other Interview Questions
|