Style rules

You use the Design CSS or Design Wizard page in the Theme editor to manage style information. Each style rule is identified by a selector, or a group of selectors, and has a set of properties.

You use the Design CSS or Design Wizard page in the Theme editor to manage style information. Each style rule is identified by a selector, or a group of selectors, and has a set of properties.

Selectors

A selector refers to one or more XML elements in the content of your web pages. So you might have a rule for each level of heading, another for paragraphs, another for tables, and so on. You can use multiple selectors to apply a set of style properties to several elements. For example, you could assign the Arial font family to all your headings.

In addition you can create more specific selectors for classes of element, or elements with individual identifiers, using the class or id attributes on web pages. An example is giving a paragraph a 'note' class that adds a colored background and a border.

The CSS specification also provides for pseudo-elements and pseudo-classes like hyperlinks, with different states for 'hover' and 'visited', and you can specify these along with attribute selectors for the full range of XDIME attributes.

Namespaces in selectors

You can qualify a selector with an XML namespace. Let's suppose that in XDIME 2 you wanted to distinguish the label in the XForms namespace from the element with the same name in the default namespace. To do so you would add the xforms prefix (without the following colon) to the label element, resulting in a selector like this.

xforms|label {
  font-family: Helvetica;
}

This approach is not needed in XDIME since no namespace prefixes are used for presentation elements. In other words, a type selector p represents the p element from either XDIME 1, or XDIME 2. However, MCS defines two default namespaces:

Prefix URI
cdm http://www.volantis.com/xmlns/marlin-cdm
xhtml2 http://www.w3.org/2002/06/xhtml2

If selectors need to be styled separately, then the appropriate prefix should be used, e.g. cdm|p to represent the selector in XDIME 1 and xhtml2|p to represent it in XDIME 2.

MCS behaves as the following hard coded mappings between namespace prefixes and namespace URIs were defined for every style sheet using @namespace rules. While possible, it is not recommended to map an existing hard coded prefix to a different URI, or a hard coded URI to a different prefix. Please note that the default mappings cannot be changed. Refer to the topic entitled At-rules for more information about the @namespace rule.

Prefix URI
cdm http://www.volantis.com/xmlns/marlin-cdm
mcs http://www.volantis.com/xmlns/2006/01/xdime/mcs
xhtml2 http://www.w3.org/2002/06/xhtml2
xforms http://www.w3.org/2002/xforms
widget http://www.volantis.com/xmlns/2006/05/widget
widget-response http://www.volantis.com/xmlns/2006/05/widget/response
ticker http://www.volantis.com/xmlns/2006/09/ticker
ticker-response http://www.volantis.com/xmlns/2006/09/ticker/response
gallery http://www.volantis.com/xmlns/2006/10/gallery-widget
cf2 http://www.volantis.com/xmlns/2009/07/cf2
ui http://www.volantis.com/xmlns/2009/07/cf2/ui
json http://www.volantis.com/xmlns/2009/07/json
cst http://www.volantis.com/xmlns/2009/07/cf2/template

Using the universal selector

The universal selector, written as a CSS qualified name with an asterisk "*" as the local name, represents any single element in the document tree within the namespace(s) indicated by the prefix. If the selector is unqualified, then it behaves as if it was bound to the default namespace.

The following table provides several examples illustrating the use of the universal selector.

Selector Description
xhtml2|*
Represents all elements in the http://www.w3.org/2002/06/xhtml2 namespace.
|*
Represents all elements in no namespace.
*|*
Represents all elements in all namespaces. Please note that a selector that has no type selector and no explicit universal selector has an implicit universal selector of *|*.
*
Represents all elements in either the http://www.volantis.com/xmlns/marlin-cdm, or http://www.w3.org/2002/06/xhtml2 namespaces.

Combining selectors

You can group simple selectors by adding or appending them to a group. When you append a selector, you can choose between child, descendant, direct adjacent sibling or indirect adjacent sibling.

Append as Description CSS Example
Child The a element with the ID 'myid' that is an immediate child of p.note.
p.note > a#myid {
  color: red;
}
Descendant All em elements anywhere inside a table.
table em {
  font-weight: bold;
}
Direct adjacent sibling A p element that immediately follows an h2 and if both elements share the same parent.
h2 + p {
  margin-top: 6px;
}
Indirect adjacent sibling A pre element that follows an h3 but not necessarily immediately. Both elements share the same parent.
h3.example ~ pre {
  font-size: 9pt;
}

Related topics