Note: This documentation is preliminary and is subject to change.
Sets or retrieves
generated content to insert before or after an element.
Syntax
HTML |
{ content : sContent }
|
---|
Scripting | [ sContent = ] object.style.content [ = v ] |
---|
Possible Values
sContent | String that
specifies or receives
a space-delimited list, including one or more of the
following values.
string |
Text content, in either double quotation marks (")
or single quotation marks (').
| counter(sCounter,[listStyle]) | Possible values include the following:
sCounter |
A counter identifier, optionally followed by
listStyle.
| listStyle |
Optional. Any of the range of values from the
listStyleType
property.
|
|
|
The property is read/write
for all objects except the following, for which it is read-only:
currentStyle.
The property has no default value. The Cascading Style Sheets (CSS) attribute is
not inherited.
Remarks
The content
attribute is used in conjunction with
:before and
:after pseudo-classes
to generate content in a document.
Strings can written with either double quotation marks (") or
with single quotation marks ('). Double quotation marks cannot occur
inside other double quotation marks, unless they are preceded by
a backslash (\) escape character. For example, the string
"\""
is interpreted as containing
one double quotation character.
It is possible to break strings over several lines, for esthetic or
other reasons, by use of the backslash as a continuation character;
however, the newline character itself is ignored.
Authors may include line breaks in the generated content
by writing the \A
escape sequence in any
of the strings after the
content
property. The generated line break is displayed in accordance
with the value of the
white-space
attribute.
The backslash is also used to generate escape characters that
cannot be represented in the current character encoding.
In this case, the backslash is followed by at most
six hexadecimal digits (from the range 0–9 and A–F)
to indicate the Unicode character with that number.
This property requires Internet Explorer
to be in IE8 mode rendering.
Example
The following example generates braces before and after
all the H1 elements on a page.
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<style type="text/css">
H1:before {
content: "{ ";
}
H1:after {
content: " }";
}
</style>
Standards Information
This property is defined in
Cascading Style Sheets (CSS), Level 2 Revision 1 (CSS2.1) .
Applies To
|
currentStyle,
runtimeStyle,
style,
A,
ABBR,
ADDRESS,
B,
BIG,
BLOCKQUOTE,
BODY,
BUTTON,
CAPTION,
CENTER,
CITE,
CODE,
COL,
COLGROUP,
DD,
DFN,
DIR,
DIV,
DL,
DT,
EM,
FIELDSET,
FORM,
hn,
HTML,
I,
IMG,
INPUT type=button,
INPUT type=checkbox,
INPUT type=file,
INPUT type=image,
INPUT type=password,
INPUT type=radio,
INPUT type=reset,
INPUT type=submit,
INPUT type=text,
KBD,
LABEL,
LEGEND,
LI,
LISTING,
MARQUEE,
MENU,
NOBR,
OL,
P,
PRE,
S,
SAMP,
SMALL,
SPAN,
STRIKE,
STRONG,
SUB,
SUP,
TABLE,
TBODY,
TD,
TEXTAREA,
TFOOT,
TH,
THEAD,
TR,
TT,
U,
UL,
VAR,
XMP |
See Also
counterIncrement, counterReset