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
<b:attr cond='CONDITION'
        name='ATTRIBUTE_NAME'  <!-- expr:name='EXPRESSION' -->
        value='VALUE'/>        <!-- expr:value='EXPRESSION' -->
  • <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
  <b:attr name='id' value='foo'/>
  <b:attr name='class' value='bar'/>
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.
<div id='foo' class='bar'>
Add an attribute with a condition
  <b:attr cond='data:view.isPost' name='style' value='background: red'/>
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.
<div style='background: transparent'>
Inject  multiple attributes
  <b:attr name='href' expr:value='data:label.url'/>
  <b:attr name='target' value='_blank'/>

Other Tag

Share This

Creative Commons License
Blogger Book is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.