Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are HTML helpers worth using with complex markup?

Should I persist with using HTML helpers, or just use plain HTML?

I've been using HTML helpers for a while now and really enjoyed using them. Recently I've started using CSS frameworks such as Twitter Bootstrap and I'm finding that my markup is too complex to use the standard HTML helpers.

Of course, I still use Url.Action() for generating links and sometimes @Html.TextBoxFor() or similar for simple forms, but, for example, I'm finding some helpers like Html.ActionLink() or Using Html.BeginForm() just don't cut it.

My markup often contains complex nests. For example, in Bootstrap I might want to add an icon as part of a link:

<a href="#">
    <i class="icon-user"></i>
    <span>Simple link</span>
</a>

This is very common with Bootstrap and I feel like HTML helpers would get in the way. I can make my own, but my markup is quite different all over.

Suppose I only use HTML helpers in small amounts; where needed. This raises another question:

If I'm minimising HTML helper usage, should I just drop them altogether and primarily use regular HTML for consistency?

like image 770
Rowan Freeman Avatar asked Jun 04 '26 23:06

Rowan Freeman


1 Answers

I agree that Html tag helper can do as much to obscure meaning as convey it. We all understand Html (designers and developers) so why not use it? Html helpers simply revert us to the days of Asp.Net controls which emitted Html for us. As an example, which of these two is clearer?

@Html.ActionLink("About this Website", "About") 

or

<a href='/about'>About this website</a> 

Granted the second answer may have more characters, but is far clearer.

like image 145
VTP Avatar answered Jun 07 '26 22:06

VTP