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 1032 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
Version 8.18.x (untested)

You must login before you can report on package compatibility.

Previously reported to work on versions:

Package Information

  • Package owner: Heather Floyd
  • Created: 25/02/2010
  • Current version 1.1
  • License MIT
  • Downloads on Our: 1.3K