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?

  1. using HTML tag builder classes

  2. direct HTML tag in entity view.

2 Answers 2


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 <div> tags).

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.