Creating custom titles using CSS

Hi,

I am trying to assign different font, color and style only to my title of the page. (I also do NOT want to assign the title as h1,h2...h6). I have used the followng css style for the title.

p.heading{

color: #2D637F;

font-family: ="Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;

font-size: 24px;

font-weight:bold;

line-height: 1.5em;}

Now the tilte content is say "Welcome". How do i use wiki mark up to assign the above css code to only this particular heading without using html macro?

plz help...Thanks!

3 answers

1 accepted

1 vote
Accepted answer

Hi Avinash,

you must make sure that the html and the css matches.

The wiki code

{div:class=heading}

My Title

{div}

creates the html code

<div class="heading">
<p>My Title</p>
</div>

So you have .heading p in html but p.heading in CSS. Change one of them to match the other and it will work.

Steffen

Thank you so much! Works like a charm! :)

You could use the span or div macros available from the Adaptavist advanced formatting plugin I believe. Those macros allow you to specify inline style attributes or a class.

I tried using div macro in the wiki markup this way

{div:class=heading}

My Title

{div}

But nothing happens. Its like i cant make it identify my heading in the markup. :(

I think Steffen may have given you a pointer to make this work. See his answer below.

You can create a custom user macro. Go to Confluence Admin > User Macros > Create a User Macro. Type "title" as Macro Name and Macro Title, and select "Rendered" for Macro Body. For template, add the following:

## @param dummy:title=dummy|type=string

<p class="heading">$body</p>

The parameter I put there is dummy since user macro requires you to put a parameter in order to include it in the Macro Browser.

Add a new page, click Insert Macro and search for "title". Add the title macro into the editor and type the title in the body of the macro.

Don't forget to put the CSS code that you mentioned above into the Stylesheet page in the Confluence Admin.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 11 hours ago in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

92 views 1 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you