CSS2 Style cssText Property

황제낙엽 2012.09.13 15:16 조회 수 : 257

sitelink1  
sitelink2  
sitelink3 http://1 
sitelink4 http://ko 
extra_vars5 http://www.w3schools.com/jsref/prop_style_csstext.asp 
extra_vars6 sitelink1 

Definition and Usage

The cssText property sets or returns the contents of a style declaration as a string.

Syntax

Set the cssText property:

Object.style.cssText="string"

Return the cssText property:

Object.style.cssText

ValueDescription
stringSpecifies the content of a style declaration


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The cssText property is supported in all major browsers.


Example

Example

Get the style declaration as a string:

<html>
<head>
<script>
function displayResult()
{
alert(document.getElementById("p1").style.cssText);
}
</script>
</head>
<body>

<p id="p1" style="border:2px dashed green;color:red;">This is a paragraph.</p>
<br />
<button type="button" onclick="displayResult()">Get style declaration</button>

</body>
</html>