Click to Rate and Give Feedback
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.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. 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
Tags What's this?: Add a tag
Community Content
 
Add Community Content
Usage Caveat      John Sudds - MSFT   |   Edit   |  

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
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker