• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
      • Introduction to Data Entry
      • Data Entry Application
      • Data Entry Editing
      • CAPI Data Entry
        • Introduction to CAPI
        • CAPI Features
        • Capture Types
        • Multimedia
        • CAPI Strategies
        • How to ...
          • Create a New CAPI Application
          • Define Languages
          • Organize Forms
          • Enter Question Text
          • Create Fills In Questions
          • Edit Styles
          • Change Formatting
          • Add Images
          • Insert Link In Question Text
          • HTML Question Text
          • Question Text Macros
          • Resource Folders
          • Use Multiple Languages
          • Create Conditional Questions
          • Structure Movement
          • Create Helps for Fields
          • Show Values for Selection
          • Handle Multiple Answers
          • Choose Topic Sections
          • Create General Helps
          • Test Application
      • Network Data Entry
      • Android Data Entry
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

HTML Question Text

Overview
For those with experience using HTML, it is possible to format the question using HTML tags and CSS styles. To view the HTML code, click on the Code button on the question text editor toolbar.
CSPro supports all tags and attributes in standard HTML5, including images, tables, and CSS styles.
The HTML for each question does not include the <html> or <body> tags. The HTML question text is inserted into to a complete HTML document that already has those tags.
Styles
All styles defined in the Edit Styles dialog are included as CSS classes in the HTML document by CSPro. These styles can therefore be used in the HTML question text by setting the class attribute of a tag to the name of one of the styles. For example:
<p>A question with <span class="instruction">a style applied to this part</span>.</p>
The normal style is applied to the <body> tag by CSPro so that all unstyled text in the question text uses the normal style.
In addition, the document created by CSPro sets the background color to yellow on Windows Desktop and to gray on Android.
Finally the document adds some basic styling to tables such as borders and padding.
External Files
References to external files such as images and stylesheets may be included in the HTML question text. All paths must be relative paths based on the location of the application (.ent or .pen) file. Absolute paths are not supported. When deploying your application, make sure to copy the external files as well or include them in a resource folder.
Using JavaScript to Interact With CSPro
You can use the Action Invoker, called using JavaScript, to interact with various CSPro features. For example, you can call user-defined functions from question text. This feature allows advanced users to take advantage of the power of JavaScript to allow some interaction between question text and CSPro logic. For example:
<p>
    You are entering person
~~curocc()~~.
    If all persons have been recorded,
<a href="#" onclick="endRoster(); return false;">end the roster (with a household size of ~~curocc() - 1~~)</a>.
</p>
<script src="/action-invoker.js"></script>
<script>
    function endRoster() {
        let CS = new CSProActionInvoker();

        CS.Logic.evalAsync({
            logic: "EndPersonRoster();"
        });
    }
</script>
To use the Action Invoker from question text, you need proper permissions granted using access tokens.
See also: HTML in CSPro, Change Formatting, Question File (.qsf)