Documentation for Confluence 5.4.
Documentation for Confluence OnDemand and earlier versions of Confluence is available too.

Skip to end of metadata
Go to start of metadata

The HTML macro allows you to add HTML code to a Confluence page.

(info) Note that the HTML macro will only be available if it has been enabled by your System Administrator.

Using the HTML Macro

To add the HTML macro to a page:

  1. In the Confluence editor, choose Insert > Other Macros.
  2. Find and select the required macro.

Speeding up macro entry with autocomplete: Type { and the beginning of the macro name, to see a list of suggested macros. Details are in Using Autocomplete.

To edit an existing macro: Click the macro placeholder and choose Edit. A macro dialog window will open, where you can edit the parameters of the macro.

There are no parameters for this macro.

Enter the HTML code into the body of the macro placeholder.

Code examples

The following examples are provided for advanced users who want to inspect or edit the underlying markup for a Confluence page. 

Macro name: html

Macro body: Text, consisting of HTML code.

Parameters: None.

Storage format example

Wikimarkup example

32 Comments

  1. Anonymous

    we want to add expandable/collapsible headings to our wiki pages. i think a combo of javascript and html is the only way to do this.

    is there also a way to add javascript to your pages?

  2. sorry, the above is me. i am not anonymous, just forgot to sign in.

    1. Hi Mark,

      Perhaps what you require is already implemented by the expand macro. If this is not what you require, you can also create your own user macro in which you can specify your JavaScript. Hope this helps.

      Cheers
      JSashi

      1. The cloak macro is a better alternative. Available in the composition plugin.

  3. Hi,

    I am trying to add an image map using the html macro in Confluence 4.1.

    My image won't display on the page, even though it is attached to the page.  I've checked the file name and it matches the code.

    This is the code I've used:

    <img src="lifecycle.gif" width="300" height="200" usemap="#shapes"/>
    <map name="shapes" id="shapes">
    <area shape="rect"
    coords="136,11,227,89"
    href="javascript:clicked_on('rectangle');"
    title="Rectangle" alt="Rectangle"/>
    </map>

     

    Can anyone suggest a fix?

     Sarah

  4. Anonymous

    Hi,

    I have some javascript and css inside the html macro, which works only in preview when adding/choosing the macro from the macro list, vut when i save the page it doesnt work. any idea?

    Tomas

    1. Anonymous

      i too have the same issue.. Have you found out a way to make it work ?

       

      Thanks

      Dinoj

  5. sample macro for executing javascript for those who need it.

  6. Anonymous

    I have enable the HTML macro. I need to access the logged user's info in that macro. How do I do that?

  7. We use phpchart on another webserver.  I want to include a page that generates a graph.

    I can include the php page but the graph is not rendered.  The graph renders via javascript.  Can I do this the html macro?

    1. The PHP script needs to be served from a CGI type server, then do xmlhttprequests from your javascript or whathave you in the macro

       

  8. my html macro works only on the preview but not after i save the page ? Why

  9. Hi I too have a same problem.. I have a HTML code inside the HTML macro with some CSS file inside the head of HTML.

    It works fine when i preview it. But the same is not reflecting when i save it.

    kindly help me.

    1. Are you using the Atlassian HTML macro or HTML Plugin for Confluence? If the later, then use head=true and make sure you are on version 4.1.0 or above.

  10. Hi Bob

    I am using Atlassian HTML Macro.. Kindly help me.

    Thanks

    1. I don't know of any way to make the Atlassian html macro work differently. Confluence ignores stuff within the header (except in preview mode). So either move the stuff into the body or use the html macro from HTML Plugin for Confluence with the parameters suggested.

  11. The ability to create content rich tech docs is the main reason we moved to Confluence, re: Dinoj, Tomas, deepak, saravanan ---when is this macro javascript only displaying on preview issue going to resolved? Is there an existing JIRA issue for this?

    1. It worked after a re load of the page for me - Please try the same

  12. Reload doesn't seem to cut it. maybe I'll try different browser versions/ I'm embedding a chart in JS, in the preview its in the right location. In the saved version its dumping it all the way at the bottom after the "Powered by Atlassian" that's also on this page. Not sure if I'm understanding correctly, does the issue for the edited page get permanently fixed after a single reload (until the next edit)? 
     

    UPDATE: Nevermind, error was in the javascript

  13. Anonymous

    Hello, is there a macro I can use so that my HTML links get rendered rather than displayed as source code? I have an HTML 5 help file stored in Subversion, which we host through JIRA. I want to add a link to Confluence so that people can pull up the HTML 5 home page of my help file, which contains a navigational link, etc. Unfortunately, no matter what I do, any kind of link I insert ends up displaying as source code, even if I click to open in new window or tab.

    Even better would be if I could display the content right inside of Confluence, like inside of an iframe or something like that. I really don't understand why this does not appear to be supported. This is a real functional gap in the product. You have support for the QA side of things, you have support for the development side of things, where is the support for the tech docs side of things?

    Thanks.

  14. Anonymous

    Is there any idea why html does not render after save? I also see the html ok in preview, but it does not show after save,
    similarly as couple of guys before. We use the confluence version 5.1

  15. Make sure your HTML is well formed. If necessary, build up from something that works (or pair down until it works) so you know what is breaking it. 

  16. Hi Bob,

    While i am adding Html code to confluence 4.3 editor,it simply displaying HTML code. I want to add css to my content while building page

    i have also tried HTML macro inside my page:

    {html}<div style="background:red">some text</div>{html}

    But it displaying error while saving/previewing.

    Kindly help..

    Thanks

    1. I just saw this now. You have probably sorted it out already, but if for others it would be helpful if you mentioned what type of error you are seeing or if there is any error indiciated in the Confluence log. 

  17. Anonymous

    Is it possible to add a template variable inside the HTML macro?

    I want to insert some iFrames where the creator should choose the source.

    When selecting the panel macro you can use the "template-dropdown", but when the html macro is selected it is greyed out.

    And there is some minor bug: If you select the HTML macro header and then the textbox below the template dropdown is selectable and it seems you can use variables, but if you try to use the template, the variables won't be loaded correctly.

     

    Can you tell me how I can use variables in the HTML macro?

    Regards, Robin

  18. Can we use this macro for image mapping?

    1. By image mapping do you mean putting clickable hotspots over images?  I imagine you would be able to if you can code it in HTML.  You might want to ask your questions at Answers as someone in the community might have already tried this. 

      1. Yes. I have looked in there. It looks like there is a free plugin for image mapping, but the documentation is no longer there and many users say they are having issues with it. I have posed a question specifically about whether you can do this in the html macro. We shall see what they say (smile)

        1. I have once created such a page. (confluence 3.5 or 4) . It works but it is hard to create and hard to support without an authoring tool.

          1. I built an mapped image using www.image-maps.com and linked back to wiki pages we built.  It works when the source of the image points to the copy on image-maps.com . But if I change the source to point to our wiki path it doesn't work.  I don't know why but I'm thinking that it can't find the image "within". I'm going to ask IT to provide a place where it can upload the image to a public folder and see how that works. I'll report my findings.

            1. We use image-maps.com to map our images and are able to get it to work. Are you uploading the image as an attachment on the page, then taking the link path for the image itself rather than the page link? That is the image source link we use and have had no issues.

              The image link would look something like this:

              http://www.test.com/download/attachments/52691011/bannertest.png?api=v2
              1. Yes, I took the wrong link. I've made the correction and everything is working. Thank you for the help.