6 votes

Dynamic Body Tag

A simple XSLT macro which you can use in your Templates to generate a dynamic opening <body> tag which includes "id" and "class" tags you can use in advanced CSS.

The "id" tag will be set equal to "Node0000" (where 0000 is your nodeid) - this allows you to do page-by-page styling in css (ex: #Node0000 h1 { color:#FFD600} which would change the color of h1 tags only on this single page).

There is an option to also add a "class" tag set equal to the alias of the template for the page, which allows you to specify CSS specific to a certain template (ex: body.SalesPage h1 { color:#FFD600} which would change the color of h1 tags only for the SalesPage template).

If you need something else included in your body tag, for instance, your own custom class tag, or margin info, you can specify that as well and it will be included.

Example usage:

<umbraco:Macro TextForTag="top-margin=&quot;0&quot;"IncludeClass="1" Alias="Util_BodyTag"runat="server"></umbraco:Macro>

would generate something like:

<body id="Node1111" class="MyTemplate" top-margin="0">

*Please Note: This only creates the opening body tag, don't forget to add a standard "</body>" tag to your template opposite of this macro*

 

Archived files

Documentation

Source code

Package owner

Heather Floyd

Heather Floyd

Heather has 627 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
8.2.x (untested)
8.1.x (untested)
8.0.x (untested)
7.15.x (untested)
7.14.x (untested)
7.13.x (untested)
7.12.x (untested)
7.11.x (untested)
7.10.x (untested)
7.9.x (untested)
7.8.x (untested)
7.7.x (untested)
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (untested)
6.0.x (untested)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Heather Floyd
  • Created: 25/02/2010
  • Current version 1.1
  • License MIT
  • Downloads: 1233