The Ultimate Style Sheet Tip in MadCap Flare

I speak with literally hundreds of Flare users every month and one frustration that I hear over and over is about the strict nature of using CSS styles in an XML environment.

People are used to creating styles in an application like Microsoft Word and then being able to use those styles anywhere. Due to the strict nature of XML if you create a paragraph CSS style then it can only be used in paragraphs. If you create a list style then it can only be used in lists, and so on. This strict enforcement can be frustrating. You have a perfectly good style called p.MyStyle that makes text neon blue, italic, underlined, and with a lime green background (because that is soooo user friendly) and you want to apply this style to the second step in your procedure…but you can’t. Since this is a paragraph style you can’t use it in the list you are using to number your procedure steps.

At this point some folks would go on to create another style called li.MyStyle and go through all of the work to match the attributes of this new style to perfectly match the paragraph version. But, this is completely unecessary! What if I where to tell you that there was a way to create a single style in your Flare CSS Style Sheet that could be used on any element, anywhere in your topics, at any time?! Well, that is exactly what we are going to do.

Creating a Paragraph Class

  1. First, open Flare and open your active CSS file in the Flare style editor.
  2. Now, select the p element in the style sheet editor. We need to select it because we are going to make a new class attached to it.
  3. Once you have the p element selected, go to the toolbar and click on the “Add Class” option.
  4. Name the new class “Tip” and click OK. You will now have a new style class called p.Tip.
  5. Add some attributes to your new style class such as a background color, border lines, etc. Add the attributes so that you can definately see a change when the style class is applied to text in your topics.

OK, now we have a standard paragraph style that can be applied to any paragraph in your project. But, try to apply this new tip style to text in a table, or in a list, or in any element that isn’t a proper paragraph and poof, your nice new style disapears from the list of available styles. Now for the magic part!

Converting a Paragraph Class to a Generic Class

  1. OK, locate your CSS file in the Content Explorer view.
  2. Right click on your CSS file and select “Open with > Internal Text Editor”
  3. Now that you have access to the actual CSS code, scroll down to the bottom and find your style p.tip.
  4. Now for the magic part. Place your cursor in front of the p in the p.tip entry and….press the delete key. You want to delete the letter p and leave the .tip part.
  5. Save the edited CSS file by clicking on the save icon on the toolbar or pressing Ctrl-S.

You now have what is called a Generic Style. Open a topic in your project and place the cursor anywhere you want, in a table, in a list, in a paragraph, and no matter where you place your cursor you should now have access to your tip style.

This is a technique that can be used to make any style settings you create available at any time anywhere in your Flare project. The most important part is that this is all perfectly legal with regards to XML and CSS and won’t cause any problems with your project.

Enjoy!

Advertisements

4 Responses to “The Ultimate Style Sheet Tip in MadCap Flare”

  1. I’m no CSS expert, so maybe this is a n00b question:

    Why would you do this rather than creating a SPAN style? I have some SPAN styles that I apply all over the place, not just in paragraphs or lists. Does this give you something that a SPAN doesn’t?

  2. SPAN styles are great for adding formatting WITHIN an existing element, but the technique I have outlined in this post will automaticaly create SPAN entries if necessary or create p. or td. or div. styles depending on how you try to apply the style. If using SPAN based styles is working for you then by all means, continue! :0) I was just trying to distribute a method that a lot of folks could possibly benefit from.

  3. Kevin Amery Says:

    To put it another way: a span class can only be used for spans. A generic class can be used for *anything*.

  4. Roy,

    The great thing about generic classes in CSS is that they can be used in both block-level elements and inline elements. So you can use in in the a element, or you can use it in a element.

    If I can, I prefer to apply my classes to the block-level item, as it seems cleaner, and is easy to remove in a find/replace down the road. The code is easier to read because you don’t have scattered s all over the place, and it is more semantic (you know that you are looking at a paragraph that is a type “tip”).

    I LOVE generic classes. Thanks for the tip.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: