AEM wrap by default each component html placed in a page with a DIV tag with an associated class named matching the component name:
This wrapper DIV is used by AEM especially for edit mode purpose. Normally you just do not care about this DIV and sometimes you can also use it in order to style your component by css.
But what happen if you want to remove this DIV?
You may ask, why I should want to remove the DIV wrapper? You may want to remove it for any reason, for example a common case you need to exactly reproduce a provided html layout that you cannot modify.
There are mainly 3 ways to hide or remove the decorator DIV wrapping component:
1. Define property cq:noDecoration=true
<?xml version="1.0" encoding="UTF-8"?>
It’s the easiest way … but I think is probably almost useless because removes it in all cases, even on edit mode … so component will result not editable at all.
2. Use IncludeOptions forceSameContext
You can place this simple Java code instruction before including the component:
It removes the DIV wrapper only for the next rendered component. So it will not apply to other included components that will continue to be wrapped on its own DIV.
It can be useful especially when you handle a component embedded into page template since you can add the instruction only if you are not in edit mode.
3. Use attribute BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE
Also this instruction is a piece of Java code you can use in a similar way as mentioned above.
Rather than the previous option, it removes the wrapper DIV for all next rendered components until the request is run out or you explicitly disable it.