REDCap supports the use of HTML tags to format text in question labels and response lists.
HTML markup tags are usually called HTML tags
- HTML tags are keywords (tag names) surrounded by angle brackets like <html>
- HTML tags normally come in pairs like <b> and </b>
- The first tag in a pair is the start tag, the second tag is the end tag
- The end tag is written like the start tag, with a forward slash before the tag name
- Start and end tags are also called opening tags and closing tags
Tags are “wrapped” around text to provide formatting instructions to the web browser. Like this:
<center>This is the Field Label</center>
In REDCap it would look like this:
Note that for some tags the closing tag is optional. Also the spelling is American English.
Paragraph (closing tag is optional)
<p>This is a new paragraph
<p>This is another new paragraph</p>
Anchor. Used to create links to other web pages.
Here is some text…<br> Here is some more text.
Line break (no closing tag)
Here is some text…<br/> Here is some more text.
<center>Centre this text</center>
Specified font characteristics.
<font size="3" color="red">This is some text!</font>
<b>Bold this text</b>
<i>Make this italic</i>
<h1>Make this a heading</h1>
Even smaller heading
Horizontal rule (no closing tag)
Include an image. The image has to be accessible from the web, not on your PC!)
Groups text that will have the same formatting.
My mother has <span style="color:blue">blue</span> eyes.
Similar to span.
<h3>This is a heading</h3>
<p>This is a paragraph.</p>
Emphasis. The effect will depend on the viewer’s browser.
<em>Emphasize this text.</em>
Strong. The effect will depend on the viewer’s browser but typically this will bold the text.
Defines a table
Defines a table column
Defines a table row
Defines a table header cell.
When not to use HTML in Field Labels and Choices
Adding HTML to a form/survey will result in the raw html being included in any PDF forms you might make in the project. They will also be included in exported data and scripts that import the data into statistical packages such as SPSS and SAS. If you need to include large sections of formatted text on a form it is often better to use a descriptive text field first. You can then use a smaller piece of text in the question itself.
CSS and Classes
Web sites use style sheets (known as CSS) to define formatting styles that can then be re-used throughout the site. Predefined styles can also be used in REDCap to apply consistent formatting.
Here is an example where a descriptive text question is used as a warning when someone tries to collect another time point in a longitudinal study without checking the enrollment status of the participant first.
The code looks like this (below). Note the use of the DIV tag to group the text that needs formatting. Style sheet elements are usually used in this way.
<div class="red" style="text-align:center;">
<h3 style="text-align:center;">Participant is not ACTIVE</h3> Please review participant status form before continuing.
You can also use yellow, green, blue, brown, gray.
Using smaller italic text for additional data in a question
Here is a common one for adding some meta-data to a question.
The code looks like:
Were antiplatelet drugs begun on any day prior to the procedure date listed above?
<span style="font-weight: lighter; font-style:italic;">(other stuff here)</span>
Text in a box and colored, centered, larger text using H3
Here is one for adding a box around some text and centering some larger text for a title.
<p style="border:1px solid black;padding:2px;">
<span style="display:block;border:1px solid grey;padding:10px;font- size: 125%;">
I am going to ask you a few questions to determine whether you are eligible to be in the study.
<span style="font-weight: normal; font-style:italic;">
[Interviewer: Ask all questions without stopping until you reach "Determine Eligibility before continuing!"]
<h3 style="text-align: center; color: #800000;">Identifying Information</h3>