Professional Documents
Culture Documents
• <!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
…
HTML <base> Element
The <base> tag specifies the base URL/target for all relative URLs in
a page:
<head>
<base href="http://www.w3schools.com/images/"
target="_blank">
</head>
HTML <link> Element
The <link> tag defines the relationship between a document and an
external resource.
The <link> tag is most used to link to style sheets:
<head>
<link rel="stylesheet" type="text/css"
href="mystyle.css">
</head>
HTML <style> Element
The <style> tag is used to define style information for an HTML
document.
Inside the <style> element you specify how HTML elements should
render in a browser:
<head>
<style type="text/css">
body {background-color:yellow}
p {color:blue}
</style>
</head>
HTML <meta> Element
Metadata is data (information) about data.
The <meta> tag provides metadata about the HTML document.
Metadata will not be displayed on the page, but will be machine
parsable.
Meta elements are typically used to specify page description,
keywords, author of the document, last modified, and other metadata.
The metadata can be used by browsers (how to display content or
reload page), search engines (keywords), or other web services.
<meta> tags always go inside the <head> element.
Examples of Use
Define keywords for search engines:
o <meta name="keywords" content="HTML, CSS, XML,
XHTML, JavaScript">
Define a description of your web page:
o <meta name="description" content="Free Web
tutorials on HTML and CSS">
Define the author of a page:
o <meta name="author" content="Hege Refsnes">
Refresh document every 30 seconds:
o <meta http-equiv="refresh" content="30">
HTML <script> Element
The <script> tag is used to define a client-side script, such as a
JavaScript.
HTML Tables
Tables are defined with the <table> tag.
A table is divided into rows (with the <tr> tag).
Each row is divided into data cells (with the <td> tag). td stands for
"table data," and holds the content of a data cell.
A <td> tag can contain text, links, images, lists, forms, other tables,
etc.
Example:
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
How the HTML code above looks in a browser:
Border Attribute
If you do not specify a border attribute, the table will be displayed
without borders. Sometimes this can be useful.
To display a table with borders, specify the border attribute:
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
…
</table>
Table Caption
Caption describes the table’s content.
The text inside the <caption> tag is rendered above the table in most
browsers.
<table border="1">
<caption> Table Example </caption>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Table Headers
Table1.html
Colspan and Rowspan Attribute
You can merge data cells with the colspan and rowspan attributes
Colspan attribute specifies the number of columns that a cell will
occupy.
<table border="1">
<tr>
<td colspan="2">This spans two columns</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
Rowspan attribute specifies the number of rows that a cell will occupy.
<table border="1">
<tr>
<td rowspan="2">This spans two rows</td>
<td>Row 1 Column 2</td>
</tr>
<tr>
<td>Row 2 Column 2</td>
</tr>
</table>
A complex example (table2.html).
Table Tags
Tag Description
<table> Defines a table
Note: The form itself is not visible. Also note that the default width of a
text field is 20 characters.
Password Field
<input type="password"> defines a password field:
<form>
Password: <input type="password" name="pwd">
</form>
How the HTML code above looks in a browser:
Comments:<br />
<textarea name = "comments" rows = "4" cols = "36">Enter
comments here.</textarea>
How the HTML code above looks in a browser:
Submit Button
<input type="submit"> defines a submit button.
A submit button is used to send form data to a server.
The data is sent to the page specified in the form's action attribute.
The file defined in the action attribute usually does something with the
received input:
<form name="input" action="html_form_action.php"
method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
How the HTML code above looks in a browser:
If you type some characters in the text field above, and click the
"Submit" button, the browser will send your input to a page called
"html_form_action.php".
Example of action attribute (PHP)
Reset Button