CSS library
The topics in this section are part of a CSS library specifically for Digital surveys. Utilize this library to determine what selectors and properties to use.
While it is required that a CSS file with the necessary CSS classes be used, it is not required that the custom CSS class field is used for each of the survey fields. It is possible to write the CSS in such a way that it simply overrides the default behavior of the surveys; once the CSS file is applied in the survey or invitation settings, the changes take effect immediately on all of the fields included in the CSS selector.
The CSS in this document uses the override approach and overrides the existing survey CSS. As such, do not add custom CSS class references to each survey field.
Because styling is specific to each website, there are no best practices on styling specifically.
Some examples contain comments as part of the CSS to make it clear what each line does. Comments are not a requirement of CSS but are good practice to make the code easy to understand and maintain. The syntax for a comment is important and affects the validity of your CSS. Comments start with the slash and asterisk and end with asterisk slash, per the following example:
Terminology is important when looking for solutions that require understanding of some specific technology. While CSS class and CSS selector are often used interchangeably, they are, in fact, quite different. See the following topics for details:
CSS class
A CSS class is used in an HTML element, as in the following example:
<div class="center">This is some text</div>
By itself, the class attribute does nothing unless there is an associated CSS file for this class. As an example, all HTML elements with the class="center" attribute are center-aligned and colored red. The CSS file then contains the following:
.center {
text-align: center;
color: red;
}
CSS selector
A CSS selector can be used to limit the styling to specific HTML elements. In the following example, only <div> elements with the class="center" attribute are center-aligned and colored red.
div.center {
text-align: center;
color: red;
}
While you can modify the CSS file to enhance a selector and alter styling of any HTML element, you cannot add content or change the actual HTML using CSS. In the above example, you cannot add class="center" to <div>, but you can create a selector in a CSS file that styles how a <div> looks.