The tag <b:attr> or attribute is an instruction tag for adding an attribute to the parent element.

<b:attr> Syntax and Attribute

Blogger XML Language
<div>
<b:attr cond='CONDITION'
        name='ATTRIBUTE_NAME'  <!-- expr:name='EXPRESSION' -->
        value='VALUE'/>        <!-- expr:value='EXPRESSION' -->
</div>
  • <b:attr> tags can also be used with prefix expression expr: in the name and value.
  • Overwrite existing attribute. 
  • Can be used multiple time, in the same parent element.
  • If parent tag is singleton or self closing, tag must be replaced by <b:tag>

<b:attr> Example

Give id and class
<div>
  <b:attr name='id' value='foo'/>
  <b:attr name='class' value='bar'/>
</div>
The new id attribute with the falue foo  will be added to the tag  <div> and attribute class with the value bar as well as the parent in the HTML rendering.
Result
<div id='foo' class='bar'>
 
</div>
Add an attribute with a condition
<div>
  <b:attr cond='data:view.isPost' name='style' value='background: red'/>
</div>
If the current view of page is Post,  new attribute style with background: red as value, will be injected to the parent tag <div> in HTML rendering.
Rendered
<div style='background: transparent'>
 
</div>
Inject  multiple attributes
<a>
  <b:attr name='href' expr:value='data:label.url'/>
  <b:attr name='target' value='_blank'/>
  <span>TITLE</span>
</a>


Other Tag

Share This

About
BloggerBasics101 is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Misc
Course