newbie question - what's the point of CHtml?

I’m going to ask a stupid question…

What’s the point of the CHtml class?

If I already know HTML, why should I learn a new syntax for a class that just creates HTML? I can just type the HTML directly.

I suppose the reason I ask is that I’m making changes to a Yii website developed by somebody else, and sometimes I encounter CHtml functions to create HTML, whereas elsewhere it’s just plain old HTML. When use one and when the other?

Thanks for your insight.

Others here are more qualified to answer this than I am. I personally use CHtml mainly for links and images. This might not come up for most people, but I was well into creating my site before I employed the url manager in the config file. If I had <a href=“index.php?r=action/controller”>Link Text</a> for every link I would have had to go to each one and change it to <a href="index.php/action/controller>Link Text</a>. Not a huge advantage, but I’m glad I didn’t have to change all that code.

There’s a wiki on CHtml that helped me a great deal,

For external links you can use the traditional notation if you want:

<a href="">Click here</a>

For internal links the best option is

echo CHtml::link('Click here', array('controller/action'));