Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Properties
 cssText Property
cssText Property

Sets or retrieves the persisted representation of the style rule.

Syntax

[ sTxt = ] object.cssText

Possible Values

sTxtString that specifies or receives the text.

The property is read/write. The property has no default value.

DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, see About Dynamic Properties.

Example

This example uses the cssText property to retrieve the Cascading Style Sheets (CSS) style set on an object.

<P ID=oPara STYLE="color:'green'; font-weight:bold">
This is the test paragraph.</P>
:
<BUTTON onclick="alert(oPara.style.cssText)">
Get CSS attributes</BUTTON>
This feature requires Microsoft Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

There is no public standard that applies to this property.

Applies To

runtimeStyle, style, styleSheet, CSSStyleSheet Constructor, CSSCurrentStyleDeclaration Constructor, CSSRuleStyleDeclaration Constructor, CSSStyleDeclaration Constructor
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Usage Caveat      John Sudds   |   Edit   |   Show History

The number of rules that can be applied at one time with cssText is 4095.

Be careful to invoke the property on the styleSheet object itself, not the HTMLElement returned by getElementById or createElement. For newly created stylesheet objects, you must first append the element to the document before you can set cssText.

var ss = document.createElement('STYLE');
document.documentElement.firstChild.appendChild(ss);
ss.styleSheet.cssText = " ... style rules go here ... ";

Tags What's this?: dhtml (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker