To see the HTML source code of a web page (for example, from Internet Explorer), click View >
Source. The following is an example of a simple HTML document:
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>
A markup language is a set of markup tags. HTML documents are described by the HTML tags.
HTML documents must start with the <!DOCTYPE html>
document type declaration. The HTML document itself begins with the <html>
tag and ends with the </html>
tag. The visible part of the HTML document is between the <body>
tag and the </body>
tag.
CSS is a style sheet language that can be used to describe the style of an HTML document or how the HTML elements should be displayed. For example as shown below, the code background-color: lightblue;
is used to display a light blue background color on the web page:
<!DOCTYPE html> <html> <head> <style> body { background-color: lightblue; } </style> </head> <body> <h1>Hello Cisco!</h1> <p>This page has a light blue background color!</p> </body> </html>
CSS can also be used to indicate the text alignment, font size, and so on.
Server-Side and Client-Side Scripting
Web scripting is used to create dynamic content on a web page in addition to the static content. There are two approaches to implement the web scriptings:
- Server-side scripting is used in web applications development which involves using scripts on a web server to produce a response that is customized for each user’s request to the website. The scripts may be written in any programming language, such as PERL, Python, PHP, and so on.
- Client-side scripting uses a language that is designed for the script to be executed by the client’s web browser. Examples of client-side scripting languages include JavaScript, Visual Basic Script, and so on.
A common way to implement a JavaScript is to define the JavaScript in a separate file, then link to the JavaScript file using the src
attribute of the script tag. In the example that is shown below, the scriptname.js file contains the JavaScript. The JavaScript is embedded in a web page using the <script type="text/javascript">
and </script>
tags.
<!DOCTYPE html> <html> <body> <script type="text/javascript" src="scriptname.js"></script> </body> </html>
Instead of specifying the JavaScript file with the src
attribute, the actual JavaScript can be written between the <script type="text/javascript">
and </script
>
tags, as shown below:
<script type="text/javascript"> document.write('Hello Cisco') </script>
The above JavaScript will render the “Hello Cisco” output on the client’s web browser.
The <script>
tag can also be used to tag the JavaScript instead of <script type="text/javascript">
as shown below. The <script type="text/javascript">
tag is required in HTML 4, but optional in HTML 5. In HTML 5, the script type defaults to text/javascript.
<script> document.write('Hello HTML 5') </script>
Leave a Reply