How to use Bootstrap tooltips at a Limesurvey survey


Tooltips are a useful feature if you want to add lengthy explanations to certain keywords or answer options at Limesurvey. Since Limesurvey v3.0 the Bootstrap framework is available for all Limesurvey templates which enables you to easily add tooltips to your survey elements. We will show you how this works.

Adding tooltips to Limesurvey survey elements

Bootstrap tooltips need to be added by using proper HTML elements. You can see these elements by switching to the source code view of the Limesurvey editor. We have highlighted default HTML elements:

Limesurvey editor source code mode
Limesurvey editor source code mode

If we now want to use a tooltip for a certain keyword we need to add an additional HTML element. Placing the keyword within a SPAN element is the recommended approach since it shouldn’t change the formatting of the text.
For highlighting the word Limesurvey and adding explanatory text using a tooltip we can use the following HTML:

<span data-toggle="tooltip" title="Limesurvey is the worldwide leading open source survey software">Limesurvey</span>

This is how it looks like at the source code mode of the Limesurvey editor:

Limesurvey tooltip code
Limesurvey tooltip code

And this is how the tooltip shows up when running the Limesurvey survey:

Limesurvey tooltip example
Limesurvey tooltip example

Tooltip core elements

As you can see from the above screenshot it only takes three core elements:

  1. HTML <span>…</span> element for adding the tooltip
  2. data-toggle=”tooltip” for indicating that the element uses a tooltip
  3. title=”Your tooltip text” for defining the to be shown tooltip text

There are some more details your can add to adjust and improve your tooltips:

  • data-html=”true” allows using HTML within the tooltip itself e.g. to highlight certain words within the tooltip with bold text, example:
    title=”Limesurvey is the worldwide <strong>leading</strong> open source survey software”
  • data-placement=”auto | top | bottom | left | right” where auto is the default value. This setting allows defining how the tooltip will be positioned.

Adjusting the tooltip styles

If you have a look at the screenshot above you will notice that the word Limesurvey is not marked in any way to indicate that it uses a tooltip. So users won’t know that additional information is available. To change this, we can add an additional CSS class mytooltip to the above element and then add styles to the custom.css file of the Limesurvey template used to highlight words with tooltips.
This is the extended HTML code for our tooltip:

<span class="mytooltip" data-toggle="tooltip" title="Limesurvey is the worldwide leading open source survey software">Limesurvey</span>

At the custom.css file we are adding the below lines of code to
a) change the cursor on hover
b) underline the word
c) show the keyword as bold text
d) highlight the tooltip keyword with a different color

    cursor: pointer;
    text-decoration: underline;
    font-weight: bold;
    color: orange;

This is what we get:

Highlighted Limesurvey tooltip
Highlighted Limesurvey tooltip

Tooltips for Limesurvey answer options

Sometimes you need to explain what a certain answer option means while you try keeping the answer text as short as possible so the answers are still easily readable. Using tooltips you can have short answer options with additional explanations being shown as tooltips. We have created an example for this as well. This is how the answer options are added at a Limesurvey single choice question:

Limesurvey answer options with tooltips
Limesurvey answer options with tooltips

And this is how it looks like at the survey:

Example of answer options with tooltips
Example of answer options with tooltips

You may notice that the tooltip element at the above example is rather small. This is because by default the size is related to the width of the underlying text. In order to increase the tooltip width for list radio or multiple choice questions we can add the following CSS code to our custom.css file:

.tooltipquestion label, 
.tooltipquestion li.checkbox-item label 
    width: 100%;
.answer-item .tooltip .tooltip-inner 
    max-width: 75%;
    margin: auto;

As you can see there is now an additional class tooltipquestion. This is needed because we need to overwrite the default styles for the labels of checkbox and radio items. To not apply this to all questions we add the class manually to all questions using tooltips. This can be set at the Display section when editing any Limesurvey question:

Limesurvey display settings
Limesurvey display settings

Lengthy tooltip are now shown like this:

Lengthy Limesurvey tooltips
Lengthy Limesurvey tooltips

Additional information and downloads

Here are some helpful links for you:

How to remove the “Exit and clear survey” button from a Limesurvey template

While you can easily remove the “Resume later” button from your Limesurvey template by de-activating the “Participant may save and resume later?” feature at “General Settings” -> “Notification & data management” of your survey, removing the “Exit and clear survey” button isn’t possible this way. So what to do?

There are two solutions, both require editing the current template so make sure you have sufficient rights for this. And of course, creating a backup first never hurts 🙂

Using CSS to remove the button

At the Limesurvey template editor select the “template.css” file and at the end add this CSS code to hide the button:

#limesurvey .clearall
   display: none;

For testing we used the <commercial_mode_on>beautiful Limesurvey template “Janus” which you can download here</commercial_mode_off>. This is how the buttons look like before the above adjustment:

with button

…and with the hidden button the result is:

without button

Removing the button placeholder from template code

The solution we recommend to use is to just remove the button placeholder from the template code. While hiding the button using CSS can cause side-effects and users can still use it when setting the browser to display hidden elements, simply removing the code from the template also does the trick.

To do so go to the Limesurvey template editor and at the “Standard files” section select the “navigator.pstpl” file. That’s where we have placed the related code for all templates from our shop.
You should see the following code at which you can simply remove the {CLEARALL} placeholder:

<div id="navigator" class="clearfix">
   <div id="left">
   <div id="right">
   <div id="middle">

Alternatively, you can comment out the placeholder so that the related code line reads:

<!-- {CLEARALL} -->

If the above doesn’t work for you and you need further help with adjusting your Limesurvey template just drop us a note.