<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 the style declaration as a string</button>
</body>
</html>