HTML and CSS Reference
In-Depth Information
object. All the various elements of the web page deined by the HTML markup
are objects and can be accessed by scripts and styled by CSS.
Example 2.3 expands on the previous versions of the Hello World page by
adding a script that adds a simple behavior to the page when the user clicks
in the body of the page. he paragraph text has been changed to keep things
interesting. Only the relevant parts of the coding are highlighted in boldface
type. Figure 2.3 shows the result of this code.
Example 2.3: An HTML page with CSS rules and HTML attributes
<!DOCTYPE html>
<html>
<head>
<title>Example 2.3</title>
<style>
h1 {
text-align: center;
color: darkblue;
}
.intro-text { font: 12pt sans-serif; }
</style>
</head>
<body>
<h1> Hello World Wide Web </h1>
<p class="intro-text">
Welcome to this webpage, <br/>
It's <em> so </em> nice to see you.
</p>
<hr/> <!-- horizontal rule -->
</body>
<!-- function to make the text red when clicked -->
<script type="text/javascript">
document.body.onclick = function () {
document.body.style.color = 'red';
}
</script>
</html>
 
 
Search WWH ::




Custom Search