How To Force Yii To Generate Valid Image Tag

As in the topic – how to force Yii, to generate <img> tag, that is valid and conforms HTML5 rules, that is – that is terminated with />, not just >?

Neither this:


<?php echo CHtml::image($path, 'Alt text', array

(

	'width'=>16,

	'height'=>16

)); ?>

nor that:


<?php echo CHtml::tag('img', array

(

	'src'=>$path,

	'alt'=>'Alt text',

	'width'=>16,

	'height'=>16

)); ?>

works. Yii in both cases generates this:


<img width="16" height="16" src="/appname/images/checkmark-guacamole.png" alt="Alt text">

that is – terminated with >, not with />.

What am I missing?

Check the actual source code of the page, not just the developer tools. Yii does generate the tag correctly by default, but the developer tools may alter it.

EDIT:

As an aside, the forward slash is not required in HTML 5 (although it is accepted) as HTML 5 isn’t a form of XML.

Thank you, Keith! Of course, you’re right! I was so devoted to using dev-tools, that I hasn’t been using Ctrl+U for ages! :]

I didn’t knew, that such things happens. What could be the purpose of changing real source code in dev tools? I can’t find any…

I got confused by Netbeans 7.4 marking this as an error (of course, when I wrote <img> tag directly, not when I used CHtml:tag). Didn’t know, that HTML5 doesn’t require ending single-tags. Good to know.

Thanks and have a great weekend!