Home >> FAQs/Tutorials >> XHTML Tutorials and Tips >> Index

XHTML 1.0 Tutorials - Document Structure and Head Level Tags

By: FYICenter.com

Part:   1  2  3  4  5  6  

(Continued from previous part...)

What Is a Script Tag/Element?

A "script" element is an optional sub-element of the "head" and many other XHTML elements. If a "script" element is placed inside the "head" element, the specified script code will not be executed immediately.

Usually, you use "script" elements in the "head" element to define script functions. and use other "script" elements in the "body" element to call those functions. Here is good example of a script element:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>My First Script Document</title>
  <script type="text/javascript">
  function hello() {
    alert("Hello world!?");
  }
  </script>
 </head>
 <body>
  <p><script type="text/javascript">
    hello();
  </script></p>
 </body>
</html>

If you save the above document as hello.html, and view it with Internet Explorer, you will see a small dialog box showing up.

What Is a Link Tag/Element?

A "link" element is an optional sub-element of the "head" element. A "link" element is used to specify Cascading Style Sheet (CSS) file. Here is good example of a link element:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>My First CSS Example</title>
  <link rel="stylesheet" type="text/css" href="_fyi.css" />
 </head>
 <body>
  <p>Hello world!</p>
 </body>
</html>

If you view the above the XHTML document, the browser will fetch _fyi.css and use its contents as CSS entries.

What Is a Style Tag/Element?

A "style" element is an optional sub-element of the "head" element. A "link" element is used to specify Cascading Style Sheet (CSS) entries. Here is good example of a style element:

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>My Second CSS Example</title>
  <style type="text/css">
    body {background-color: #dddddd}
  </style>
 </head>
 <body>
  <p>Hello world!</p>
 </body>
</html>

If you save the above document as hello.html, and view it with Internet Explorer, you will see a gray background specified by the CSS entry in the "style" element.

Part:   1  2  3  4  5  6  


Selected Developer Jobs:

More...