Skip to end of metadata
Go to start of metadata

Description

The Div macro wraps content in a div tag with optional class and styles. 

The div tag is a non-visual (by default) element that can be used to apply additional properties to content contained within it.

Unlike the span tag, a div stretches to fill the available width of it's containing element making it ideal for use with blocks of content such as a whole paragraph.

This macro is primarily designed for use with the Style Sheet as this would make it easy to apply custom styles to content. Alternatively you can specify specific styles for each use of the macro.

Usage

Click Insert > Other Macros.

 

Select the Div macro from the provided list.

 

Complete the desired fields.

ParameterDescriptionType

Default

Required?
ID

Specify a unique id for the element.

string

none

(error)

ClassThe class to associate with the div. Multiple classes can be specified by separating them with spaces.stringnone

(error)

StyleAn optional inline style sheet to apply to an individual div tag.stringnone

(error)

TitleText to display in a tooltip.stringnone

(error)

Text DirectionSets the text direction.single selectnone

(error)

Language CodeSets the language code.stringnone

(error)

At least one parameter must be specified

Although not strictly required to insert the macro on to a page, the macro does require one of the parameters above to be specified to function properly.

 

The macro will then appear on the page.

 

Examples:

Custom Class

To define a custom class, use the "class" parameter.

With the Class parameter set to "warningMacro".

This will add the following HTML to the page.

<div class="warningMacro">This is a div example</div>

Resulting in:

This is a div example

In this example, we've hijacked the "warningMacro" class used by the warning macro to put a red border and background on the text contained within the div.

 

Inline Styles

In our last example, we applied a background and border to some content, but there wasn't any padding between the border and the text. To rectify this we can use an inline style, and make the border a bit bigger.

With the Style parameter set to "padding:3px;border-width:5px".

This will add the following HTML to your page:

<div class="warningMacro" style="padding:3px;border-width:5px">This is a span example</div>

Resulting in:

This is a div example

If you are using the same inline style several times, create a stylesheet for the class using either the Style Sheet or the Builder - CSS Custom Styles feature of the Builder theme.

 

Frequently Asked Questions:

Q

Where can I learn more about CSS and Div tags?

A

Try

http://www.w3schools.com

as they have full tutorials on CSS and HTML.

Q

My nested DIVs aren't displaying properly

A

Confluence doesn't support nested tags, so the following were created to support nested DIVs:

  • {div2
  • {div3
  • {div4
  • {div5
  • {div6
  • {div7
  • {div8
  • {div9
    They are duplicates of the div macro, and support the same parameters.

Q

My div tag is outputting </div> at the start instead of <div> - why?

A

You must specify one or more of the parameters (style and/or class) for the macro to work properly.

See Also:

 

Top of page

  • No labels