Add CSS Class to CMS Block in Magento

blocks

Add CSS class to {{block type="cms/block" block_id="my_block1"}}

This now outputs as html here, but I see widget block add a DIV tag around it with a CSS ID.

Question: How can we add a tag around block type="cms/block" and echo some css class like the BlockId()

<div class="cms-block my_block1">html here</div> where my_block1 is the block id

Best Answer

You cannot do that unless you want to overwrite template for it. Widget block and a DIV tag you are seeing are coming from default widget handler.

If all you want to add css class then how about this way? Wrapping with div?

<div class="cms-block my_block1">{{block type="cms/block" block_id="my_block1"}}</div>

Hope this helps.

UPDATE

Check template file called template/cms/widget/static_block/default.phtml. This file is responsible for that DIV.

Related Topic