Local style overrides are a major new feature, and it's possible some new issues will surface. If you find something, please let us know.
In Content XML (CXML) 3.2, you can style paragraphs (<p>
), tables (<table>
), and table cells (<entry>
) via local overrides using the @style
attribute. If you're familiar with Cascading Style Sheets (CSS) syntax, then the values for the @style
attribute will be familiar as well.
The value of the @style
attribute is one or more style rules, separated by a semi-colon (;). Each style rule contains a property, followed by a colon (:), and a list of values.
Here is an example of a table cell (<entry>
) styled with the @style
attribute:
In this example, border-left
, border-right
, and border-background
are the properties; and 4px dotted rgb(123,15,15)
, 4px solid #CCFF14
, and namedColor(Pantone 353C) 45%
are the values.
Like CSS, CXML style rules can also use a shorthand form to set the values of multiple properties simultaneously. For instance, the border
property is a shorthand for the four border-top
, border-left
, border-bottom
, and border-right
properties. For more details about how to use shorthands, see Shorthand properties. Using shorthand properties helps you write more concise (and often more readable) style rules, saving time and energy. 👍
White space at the beginning and end of a style rule is ignored so you can use line breaks and indentation for better visibility.
Limitations
- Local style overrides are not validated—Typefi ignores any invalid style rules.
- Local style overrides are lost when roundtripping content.
- Existing event scripts may interfere with style overrides.
Properties
Background
Use background
as a shorthand to specify the text color and tint of paragraph (<p>
) or the background fill and tint of table cell (<entry>
) elements.
Property | Value | Description |
---|---|---|
background | color: a hexadecimal, RGB, CMYK value, or namedColor() function tint: a number between 0 and 100, followed by a percentage sign (%) |
color: If you use the namedColor function (for example, namedColor(Pantone345C) ), the swatch should already be present in the InDesign template, or the base color for it will be unexpected.tint: Optional. The default tint value is 100%. You can optionally include a space between the number and percentage sign. |
A paragraph with a burnt orange background color at a 70% tint:
A table cell with a magenta background color at a 90% tint:
A table cell with a magenta background color at a 100% tint:
Background fill
Use background-fill
to specify a background highlight color for a paragraph (<p>
) or the cell color in table cell (<entry>
) elements.
Property | Value | Description |
---|---|---|
background-fill | A hexadecimal, RGB, CMYK value, or namedColor() function | If you use the namedColor function (for example, namedColor(Pantone345C) ), the swatch should already be present in the InDesign template, or the base color for it will be unexpected. |
Four paragraphs with similar background fill colors, specified in different ways: The colors look similar, but each has a different composition depending on the color management system used.
Background tint
Use background-tint
to specify the tint of the background fill.
Property | Value | Description |
---|---|---|
background-tint | A number between 0 and 100, followed by a percentage sign (%) | Optionally, you can include a space between the number and percentage sign. The default value is 100%. |
A table cell with a 70% background tint:
Break
There are three ways you can insert breaks in CXML:
Method | Description |
---|---|
Inserting a <break> element |
Recommended. Inserts a literal break character in the InDesign template. |
Inserting a break style override |
Overrides the paragraph style Keep Options set in the InDesign template. |
Inserting a page-break style override |
Legacy. Inserts a page break regardless of where the content falls on the page. |
Break
Use break
to override the paragraph style settings in the InDesign template and insert a break. Use on paragraph (<p>
) and table cell (<entry>
) elements .
Property | Value | Description |
---|---|---|
break | "column" "frame" "evenPage" "oddPage" "page" "anywhere" |
Replaces the old page-break override. Specify exactly the content should break. If "anywhere" is used, the start position is determined by the paragraph style's Keep Line Settings option. |
Applying a break to a paragraph:
Page break
Use break
for greater control over where the content should break.
Use page-break
to specify if the content should start on the next page. Use on paragraph (<p>
) and table cell (<entry>
) elements.
Property | Value | Description |
---|---|---|
page-break | true false |
True means the content will start on the next page. False means the content will not start on the next page.page-break is applied regardless of where the content falls on the page—if the content falls on the top of the page, and page-break is set to true, a new page is still generated. |
Applying a page break to a paragraph:
Border
Use border
as a shorthand to specify the border width, style, and color (fill color and tint). Use on table (<table>
), table cell (<entry>
) and paragraph (<p>
) elements.
Property | Value | Description |
---|---|---|
border | width: a number followed by a unit of measure ("pt", "px", "mm", "cm", or "in") style: "solid", "dashed", "double", "dotted" color: a hexadecimal, RGB, CMYK value, or namedColor() function tint: a number between 0 and 100, followed by a percentage sign (%) |
Shorthand for border-top, border-left, border-bottom, and border-right. width: You can optionally include a space between the number and unit of measure. style: "solid", "dashed", "double", and "dotted" are the only currently supported values. color: If you use the namedColor function (for example, namedColor(Pantone345C) ), the swatch should already be present in the InDesign template, or the base color for it will be unexpected.tint: Optional. The default value is 100%. You can optionally include a space between the number and percentage sign. |
A table with a 4pt, dotted, green border at an 80% tint around all four sides:
Width
You can specify the border width in several ways:
Specify the same border width for all four sides
Property | Value | Description |
---|---|---|
border | A number followed by a unit of measure ("pt", "px", "mm", "cm", or "in") | You can optionally include a space between the number and unit of measure. |
A paragraph with a 2pt border on all sides:
A list of numbers can be replaced by a single number, which means the border widths are equal for all four sides. For example: "border: 4pt 4pt 4pt 4pt"
is the same as "border: 4pt"
.
If you want different border widths for different sides
Property | Value | Description |
---|---|---|
border | A list of four numbers followed by units of measure ("pt", "px", "mm", "cm", or "in"). The order is top-left-bottom-right. | The units of measure in the list can be different from each other. You can optionally include a space between the number and unit of measure. |
A paragraph with different border widths on each side:
Specify the border width and other properties (style, color, and tint) of a specific side
Property | Value | Description |
---|---|---|
border-top border-left border-bottom border-right |
width: a single number followed by a unit of measure ("pt", "px", "mm", "cm", or "in") style: "solid", "dashed", "double", "dotted" color: a hexadecimal, RGB, CMYK value, or namedColor() function tint: a number between 0 and 100, followed by a percentage sign (%) |
width: You can optionally include a space between the number and unit of measure. style: Optional. "solid", "dashed", "double", and "dotted" are the only currently supported values. |
A paragraph with a 4pt, bright green border only on the bottom side:
If you only want to specify the border width of a specific side
Property | Value | Description |
---|---|---|
border-top-width border-left-width border-bottom-width border-right-width |
A number followed by a unit of measure ("pt", "px", "mm", "cm", or "in") | You can optionally include a space between the number and unit of measure. |
A paragraph with a 4pt border only on the bottom side:
Style
You can specify the appearance of the border line style:
Property | Value | Description |
---|---|---|
border-top-style border-left-style border-bottom-style border-right-style |
"solid" "dashed" "double" "dotted" |
"solid", "dashed", "double", and "dotted" are the only supported values. |
A table cell with a dashed border on the top side:
Color
You can specify the border fill color and tint in several ways.
Specify the border fill color and tint for a specific side
Property | Value | Description |
---|---|---|
border-top-color border-left-color border-bottom-color border-right-color |
color: a hexadecimal, RGB, CMYK value, or namedColor() function tint: a number between 0 and 100, followed by a percentage sign (%) |
color: If you use the namedColor function (for example, namedColor(Pantone345C) ), the swatch should already be present in the InDesign template, or the base color for it will be unexpected.tint: Optional. The default value is 100%. You can optionally include a space between the number and percentage sign. |
A paragraph with a bright green border at a 70% tint on the bottom side:
Specify the border fill color for a specific side
Property | Value | Description |
---|---|---|
border-top-color-fill border-left-color-fill border-bottom-color-fill border-right-color-fill |
A hexadecimal, RGB, CMYK value, or namedColor() function | If you use the namedColor function (for example, namedColor(Pantone345C) ), the swatch should already be present in the InDesign template, or the base color for it will be unexpected. |
A paragraph with a bright green border on the left side:
Specify the tint of the border color for a specific side
Property | Value | Description |
---|---|---|
border-top-color-tint border-left-color-tint border-bottom-color-tint border-right-color-tint |
A number between 0 and 100, followed by a percentage sign (%) | You can optionally include a space between the number and percentage sign. The default value is 100%. |
A paragraph with a 2pt bright green border on all sides and the bottom border has a 50% tint:
Font
Use font
as a shorthand to specify the font size, family, style, and color of text within table (<table>
), table cell (<entry>
), and paragraph (<p>
) elements.
Property | Value | Description |
---|---|---|
font | font-size: two numbers separated by a slash (/), followed by a unit of measure ("pt", "px", "mm", "cm", or "in") font-family: string font-style: "bold", "italic", "bold-italic" font-color: a hexadecimal, RGB, CMYK value, or namedColor() function |
font-size: The first number represents the font size, and the second number represents the font leading. Optionally, you can include a space between the number and unit of measure. font-family: Use single or double quotes. The string value must be the name of the font family. font-style: "bold", "italic", "bold-italic" are the only supported values. If the text already has paragraph or character styles applied, the styles are removed from the text before the override is applied. font-color: If you use the namedColor function (for example, namedColor(Pantone345C) ), the swatch should already be present in the InDesign template, or the base color for it will be unexpected. |
A paragraph with the font size, family, style, and color specified:
Font size
Use font-size
to specify the font size and leading.
Property | Value | Description |
---|---|---|
font-size | two numbers separated by a slash (/), followed by a unit of measure ("pt", "px", "mm", "cm", or "in") | The first number represents the font size, and the second number represents the font leading. Optionally, you can include a space between the number and unit of measure. If you do not set leading on the font size, it will use automatic leading in InDesign. |
Two paragraphs with the same font size and leading:
Font family
Use font-family
to specify the font family.
Property | Value | Description |
---|---|---|
font-family | string | Use single or double quotes. The string value must be the name of the font family. |
A table cell in Times New Roman font:
Font style
Use font-style
to specify the font style.
Property | Value | Description |
---|---|---|
font-style | "bold" "italic" "bold-italic" |
Currently, "bold", "italic", and "bold-italic" are the only supported style values.font-style overrules any existing paragraph or character styles. For example, if a paragraph style has bold defined, and then you apply "font-style: italic" , the paragraph will be italic, not bold italic. |
A bold, italicized paragraph:
Font color
Use font-color
to specify the font color.
Property | Value | Description |
---|---|---|
font-color | A hexadecimal, RGB, CMYK value, or namedColor() function | If you use the namedColor function (for example, namedColor(Pantone345C) ), the swatch should already be present in the InDesign template, or the base color for it will be unexpected. |
Four paragraphs with the same font color:
Paragraph alignment
Use text-align
as a shorthand to specify the alignment on paragraph (<p>
) elements.
Property | Value | Description |
---|---|---|
text-align | left right center centre justify justifyLeft justifyCenter justifyFull |
Specifies the horizontal alignment of text. The default value is "left". |
Paragraph indents
Use paragraph-indents
as a shorthand to specify the indent on paragraph (<p>
) elements.
Property | Value | Description |
---|---|---|
paragraph-indents | A number followed by a unit of measure ("pt", "px", "mm", "cm", or "in") | Shorthand for the paragraph-indents-first, paragraph-indents-left, paragraph-indents-last, and paragraph-indents-right properties. Optionally, you can include a space between the number and unit of measure. You can use a negative number to represent a negative (hanging) indent. |
A paragraph with a 4mm indent:
You can also specify the indent of individual paragraph lines
Property | Value | Description |
---|---|---|
paragraph-indents-first paragraph-indents-left paragraph-indents-last paragraph-indents-right |
A number followed by a unit of measure ("pt", "px", "mm", "cm", or "in") | Shorthand for the paragraph-indents-first, paragraph-indents-left, paragraph-indents-last, and paragraph-indents-right properties. Optionally, you can include a space between the number and unit of measure. You can use a negative number to represent a negative (hanging) indent. |
A paragraph with a 4mm hanging right indent:
Comments
0 comments
Please sign in to leave a comment.