HTML and Js
HTML and Js
--> Formatting <acronym> <abbr> <address> <b> <bdo> <big> <blockquote> <center> <cite> <code> <del> <dfn> <em> <font> <i> <ins> <kbd> <pre> <q> <s> <samp> <small> <strike> <strong> <sub> <sup> <tt> <u> <var> <xmp> Forms <form> <input /> <textarea> <button> <select>
Description Defines the document type Defines an HTML document Defines the document's body Defines HTML headings Defines a paragraph Inserts a single line break Defines a horizontal line Defines a comment Defines an acronym Defines an abbreviation Defines contact information for the author/owner of a document Defines bold text Overrides the current text direction Defines big text Defines a long quotation Deprecated. Defines centered text Defines a citation Defines a piece of computer code Defines text that has been deleted from a document Defines a definition term Defines emphasized text Deprecated. Defines font, color, and size for text Defines italic text Defines text that has been inserted into a document Defines keyboard input Defines preformatted text Defines a short quotation Deprecated. Defines strikethrough text Defines sample output from a computer program Defines smaller text Deprecated. Defines strikethrough text Defines strong text Defines subscripted text Defines superscripted text Defines teletype text Deprecated. Defines underlined text Defines a variable Deprecated. Defines preformatted text Defines an HTML form for user input Defines an input control Defines a multiline input control (text area) Defines a clickable button Defines a drop-down list
DTD STF STF STF STF STF STF STF STF STF STF STF STF STF STF STF TF STF STF STF STF STF TF STF STF STF STF STF TF STF STF TF STF STF STF STF TF STF
<optgroup> <option> <label> <fieldset> <legend> Frames <frame /> <frameset> <noframes> <iframe> Images <img /> <map> <area /> Links <a> <link /> Lists <ul> <ol> <li> <dir> <dl> <dt> <dd> <menu> Tables <table> <caption> <th> <tr> <td> <thead> <tbody> <tfoot> <col /> <colgroup> Styles <style> <div> <span> Meta Info <head> <title> <meta> <base /> <basefont /> Programming <script> <noscript>
Defines a group of related options in a drop-down list Defines an option in a drop-down list Defines a label for an <input> element Groups related elements in a form Defines a caption for a <fieldset> element Defines a window (a frame) in a frameset Defines a set of frames Defines an alternate content for users that do not support frames Defines an inline frame Defines an image Defines an image-map Defines an area inside an image-map Defines an anchor Defines the relationship between a document and an external resource Defines an unordered list Defines an ordered list Defines a list item Deprecated. Defines a directory list Defines a definition list Defines an item in a definition list Defines a description of an item in a definition list Deprecated. Defines a menu list Defines a table Defines a table caption Defines a header cell in a table Defines a row in a table Defines a cell in a table Groups the header content in a table Groups the body content in a table Groups the footer content in a table Defines attribute values for one or more columns in a table Defines a group of columns in a table for formatting Defines style information for a document Defines a section in a document Defines a section in a document Defines information about the document Defines the document title Defines metadata about an HTML document Specifies the base URL/target for all relative URLs in a document Deprecated. Specifies a default color, size, or font for all the text in a document Defines a client-side script
STF STF STF STF STF F F TF TF STF STF STF STF STF STF STF STF TF STF STF STF TF STF STF STF STF STF STF STF STF STF STF STF STF STF STF STF STF STF TF
STF
Defines an alternate content for users that do not support client-side scripts STF
Deprecated. Defines an embedded applet Defines an embedded object Defines a parameter for an object
TF STF STF
DHTML is NOT a language. DHTML is a TERM describing the art of making dynamic and interactive web pages. DHTML combines HTML, JavaScript, the HTML DOM, and CSS.
DHTML is the art of combining HTML, JavaScript, DOM, and CSS.
HTML
The W3C HTML 4 standard has rich support for dynamic content:
HTML supports JavaScript HTML supports the Document Object Model (DOM) HTML supports HTML Events HTML supports Cascading Style Sheets (CSS)
DHTML is about using these features, to create dynamic and interactive web pages.
JavaScript
JavaScript is the most popular scripting language on the internet, and it works in all major browsers. DHTML is about using JavaScript to control, access and manipulate HTML elements. You can read more about JavaScript in the next chapter of this tutorial.
HTML DOM
The HTML DOM is a W3C standard. It describes the Document Object Model for HTML. The HTML DOM defines a standard way for accessing and manipulating HTML documents. DHTML is about using the DOM to access and manipulate HTML elements. You can read more about the HTML DOM in a later chapter of this tutorial.
HTML Events
HTML events are a part of the HTML DOM. DHTML is about creating web pages that reacts to (user)events. You can read more about events in a later chapter of this tutorial.
CSS
CSS defines how to display HTML elements. DHTML is about using JavaScript and the HTML DOM to change the style and positioning of HTML elements.
JavaScript Alone
In JavaScript, the statement: document.write(), is used to write output to a web page.
Example
The following example uses JavaScript to display the current date and time on a page:
Example
<html> <body> <script type="text/javascript"> document.write(Date()); </script> </body> </html>
document.getElementById(id).innerHTML=new HTML
To change the attribute of an HTML element:
document.getElementById(id).attribute=new value
onclick=JavaScript
document.getElementById(id).style.property=new style
A Document Object Model for HTML A standard programming interface for HTML Platform- and language-independent A W3C standard
The HTML DOM defines the objects and properties of all HTML elements, and the methods(interface) to access them. In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML elements.
Example
<html> <body> <h1 id="header">Old Header</h1> <script type="text/javascript"> document.getElementById("header").innerHTML="New Header"; </script> </body> </html>
JavaScript is THE scripting language of the Web. JavaScript is used in billions of Web pages to add functionality, validate forms, communicate with the server, and much more.
What is JavaScript?
JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight programming language
JavaScript is usually embedded directly into HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation) Everyone can use JavaScript without purchasing a license
Example
<html> <body> <h1>My First Web Page</h1> <script type="text/javascript"> document.write("<p>" + Date() + "</p>"); </script> </body> </html>
Example
<html> <body> <h1>My First Web Page</h1> <p id="demo"></p>
JavaScript in <body>
The example below writes the current date into an existing <p> element when the page loads:
Example
<html> <body> <h1>My First Web Page</h1> <p id="demo"></p> <script type="text/javascript"> document.getElementById("demo").innerHTML=Date(); </script> </body> </html>
JavaScript in <head>
The example below calls a function when a button is clicked:
Example
<html> <head> <script type="text/javascript"> function displayDate() { document.getElementById("demo").innerHTML=Date(); } </script> </head> <body> <h1>My First Web Page</h1> <p id="demo"></p> <button type="button" onclick="displayDate()">Display Date</button> </body> </html>
Example
<html> <head> <script type="text/javascript" src="xxx.js"></script> </head> <body> </body> </html>
JavaScript Statements
A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do. This JavaScript statement tells the browser to write "Hello Dolly" to the web page:
document.write("Hello Dolly");
JavaScript Code
JavaScript code (or just JavaScript) is a sequence of JavaScript statements. Each statement is executed by the browser in the sequence they are written. This example will write a heading and two paragraphs to a web page:
Example
<script type="text/javascript"> document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); </script>
JavaScript Blocks
JavaScript statements can be grouped together in blocks. Blocks start with a left curly bracket {, and end with a right curly bracket }. The purpose of a block is to make the sequence of statements execute together. This example will write a heading and two paragraphs to a web page:
Example
<script type="text/javascript"> { document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); } </script>
document.getElementById(id).innerHTML=new HTML
To change the attribute of an HTML element:
document.getElementById(id).attribute=new value