HTML and CSS Reference
In-Depth Information
Table 15.5
Properties to Represent HTML Attributes (continued)
Property
Description
Example
style
Value of the CSS inline style attribute (CSS2)
div.style.color="green";
(see Section 14.5.2
)
title
Returns the title of the document found
between the
<title>
and
</title>
tags
<title>My Book</title>
strTitle = document.title
strTitle
contains “My Book”
EXAMPLE
15.4
<html>
<head><title>Properties</title>
1
<style>
.color
{ color:darkblue; background:aqua;}
</style>
</head>
<body>
2
<p
id="paraid1" dir="ltr" class=color
style="font-size:x-large"
>
This is an English style.
</p>
3
<p
id="paraid2" dir="rtl" class="color" style="font-
family:cursive"
>
This is Hebrew style.
</p>
<big>
<script type="text/javascript">
4
p1=document.getElementById('paraid1')
;
5
document.write("The text direction is "+
p1.dir
+
"and the font size is "+
p1.style.fontSize)
;
6
p2=document.getElementById('paraid2')
;
document.write("<br />The text direction is "+
p2.dir
+
" and the class name is "+
p2.className
);
</script>
</big>
</body>
</html>
EXPLANATION
1
A CSS style contains a class called .
color
to be used by elements within the HTML
page.
2
The
p
element is assigned a number of attributes:
id
,
dir
,
class
, and
style
, all avail-
able in a JavaScript program to either change or display values.