There are some HTMLTag Builder classes in common-api module for generating the HTML tags like (A, span... )
Which one is the best practice for writing entity view?
using HTML tag builder classes
direct HTML tag in entity view.
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It only takes a minute to sign up.Sign up to join this community
I think this question goes beyond the scope of just DXA, as many frameworks use this type of approach.
In general it all depends on how much control you want/need to have on the generated markup. SDL provided html helpers will, for instance, also add semantic information to the markup and include Experience Manager metadata (in staging sites). If you upgrade DXA and there are some required changes to the markup, then by using the helpers you would be getting these changes immediately.
I am sure there's other reasons to use HTML Helper classes, this could be a good place to start for that discussion.
In addition to Nuno's answer (I agree with his classification that this indeed goes beyond the scope of just DXA), I would say the best practice around using HTML inside a view and the usage of HTML Helper classes to generate HTML tags comes down to how static or dynamic your HTML in the view needs to be.
When you have some simple static HTML tags that you need to write out, you should just do that inside the view. Typical things like the markup that is part of your HTML design (probably mostly
When you need the HTML to be more dynamic, rather than coding all the conditional statements in your view, it makes sense to use an HTML Helper Class instead.