Professional Documents
Culture Documents
HTML
HTML
The <html> tag tells the browser that this is an HTML document.
The html element is the outermost element in HTML and XHTML documents. The html
element is also known as the root element.
The <h1> to <h6> tags are used to define HTML headings.
<h1> defines the largest heading and <h6> defines the smallest heading.
Attribute –align(left, center, right, justify )
Title
The <a> tag defines an anchor. An anchor can be used in two ways:
To create a link to another document, by using the href attribute
To create a bookmark inside a document, by using the name attribute
The a element is usually referred to as a link or a hyperlink.
The most important attribute of the a element is the href attribute, which indicates the
link’s destination.
By default, links will appear as follows in all browsers:
An unvisited link is underlined and blue
A visited link is underlined and purple
An active link is underlined and red
Attribute –target(_parent, _top, _blank, _self), href- url, name
examples:
<html><body><p>
This is a link to <a href="http://www.google.com/">Google</a>.
</p><p>This is a link to our <a href="default.asp" target=”_blank”>HTML reference</a>.</p>
</body></html>
1
Link to a location on the same window
<html><body>
<p><a href="#C4">See also Chapter 4</a></p>< h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p><h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p><h2><a name="C4">Chapter 4</a></h2>
<p>This chapter explains ba bla bla</p></body></html>
P tag
The <font> tag specifies the font face, font size, and font color of text.
Color—rgb(x,x,x),#hex_num,name
Example:
<html><body><p><font size="3" color="red">This is some text!</font></p>
<p><font size="2" color="blue">This is some text!</font></p>
<p><font face="verdana" color="green">This is some text!</font></p>
</body></html>
<base>
The <base> tag specifies a default address or a default target for all links on a page.
The <base> tag goes inside the head element.
<img>
2
Attributes:
Action:The required action attribute specifies where to send the form-data when a form is
submitted. <form action="value">
Value--Where to send the form data.
Possible values:
An absolute URL - points to another web site (like
action="http://www.example.com/example.htm")
A relative URL - points to a file within a web site (like action="example.htm")
The method attribute specifies how to send form-data (the form-data is sent to the page specified
in the action attribute).
The form-data can be sent as URL variables (with method="get") or as HTTP post (with
method="post").
Notes on the "get" method:
o This method appends the form-data to the URL in name/value pairs
o This method is useful for form submissions where a user want to bookmark the result
o There is a limit to how much data you can place in a URL (varies between browsers),
therefore, you cannot be sure that all of the form-data will be correctly transferred
o Never use the "get" method to pass sensitive information! (password or other sensitive
information will be visible in the browser's address bar)
Notes on the "post" method:
o This method sends the form-data as an HTTP post transaction
o Form submissions with the "post" method cannot be bookmarked
o The "post" method is more robust and secure than "get", and "post" does not have size
limitations
target
_blank, _top, _parent, _self
<input>
The <input> tag is used to select user information.
An input field can vary in many ways, depending on the type attribute. An input field can
be a text field, a checkbox, a password field, a radio button, a button, and more.
Attributes:
type —<input type="value" />
text
<input type="text" /> defines a one-line input field that a user can enter text into.
Example
Email: <input type="text" name="email" value=”@gmail.com”/><br />
Pin: <input type="text" name="pin" />
Button
<input type="button" /> defines a clickable button, that does not do anything. The button
type is most often used to activate a JavaScript when a user clicks on the button.
<input type="button" value="Click me" onclick="msg()" />
Checkbox
<input type="checkbox" /> defines a checkbox. Checkboxes let a user select one or more
options of a limited number of choices.
3
<input type="checkbox" name="vehicle" value="Bike" /> I have a bike<br />
<input type="checkbox" name="vehicle" value="Car" checked=”checked”/> I have a car
File
<input type="file" /> is used for file uploads.
<input type="file" />
Hidden
<input type="hidden" /> defines a hidden field. A hidden field is not visible for the user.
Hidden fields often store a default value, or have their value changed by a JavaScript.
<input type="hidden" name="country" value="Norway" />
Image
<input type="image" /> defines an image as a submit button.
The src and alt attribute are required with <input type="image">.
<input type="image" src="submit.gif" alt="Submit" />
Password
<input type="password" /> defines a password field. The characters in a password field
are masked (shown as asterisks or circles).
<input type="password" name="pwd" />
Radio
<input type="radio" /> defines a radio button. Radio buttons let a user select only one of
a limited number of choices.
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
Reset Button
<input type="reset" /> defines a reset button. A reset button resets all form fields to their
initial values.
Tip: Use the reset button carefully! It can be annoying for users who accidentally activate
the reset button.
<input type="reset" />
Submit
<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.
<form action="form_action.asp" method="get">
Email: <input type="text" name="email" /><br />
<input type="submit" />
</form>
Accept
The accept attribute is only used with <input type="file"> and it specifies the types of
files that can be submitted through a file upload. <input accept="value" />
Checked
Specifies that an input element should be preselected when the page loads (for
type="checkbox" or type="radio")
The checked attribute specifies that an input element should be preselected when the page
loads.
The checked attribute is used with <input type="checkbox"> or <input type="radio">.
The checked attribute can also be set after the page load, with a JavaScript.
4
Disabled
The disabled attribute specifies that an input element should be disabled.
A disabled input element is unusable and un-clickable.
The disabled attribute can be set to keep a user from using an input field until some other
condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to
remove the disabled value, and make the input element usable.
Readonly
The readonly attribute specifies that an input field should be read-only.
A read-only field cannot be modified. However, a user can tab to it, highlight it, and copy
the text from it.
The readonly attribute can be set to keep a user from changing the value until some other
condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to
remove the readonly value, and make the input field editable.
The readonly attribute can be used with <input type="text"> or <input type="password">
<table>
5
align
<TD>
The <td> tag defines a standard cell in an HTML table.
Ex:
<td valign="baseline" style="color:red; font-size:200%">$80</td>
An HTML table has two kinds of cells:
Header cells - contains header information (created with the th element)
Standard cells - contains data (created with the td element)
The text in a th element is bold and centered.
The text in a td element is regular and left-aligned.
Attributes:
Align, bgcolor
colspan- The colspan attribute defines the number of columns a cell should span.
Rowspan- The rowspan attribute defines the number of rows a cell should span.
height,width,valign
<tfoot>
The <tfoot> tag is used to group the footer content in an HTML table.
The tfoot element should be used in conjunction with the thead and tbody elements.
The thead element is used to group the header content in an HTML table and the tbody
element is used to group the body content in an HTML table.
<th>
The <th> tag defines a header cell in an HTML table.
An HTML table has two kinds of cells:
Header cells - contains header information (created with the th element)
Standard cells - contains data (created with the td element)
The text in a th element is bold and centered.
The text in a td element is regular and left-aligned.
<tr>
6
The frameset element states only how many columns or rows there will be in the
frameset.
The rows attribute specifies the size of, and the number of rows in a frameset.
Each frame’s height is specified in the rows attribute in a comma-separated list.
The cols attribute specifies the size of, and the number of columns in a frameset.
Each frame’s width is specified in the cols attribute in a comma-separated list.
<html>
<frameset rows=”30%,*”><frameset cols="25%,*,25%">
<frame src="frame_a.htm" /> <frame src="frame_b.htm" />
<frame src="frame_c.htm" /></frameset>
</html>
Frame:
The <frame> tag defines one particular window (frame) within a frameset.
Each frame in a frameset can have different attributes, such as border, scrolling, the
ability to resize, etc.
Attributes:
Scrolling-yes,no,auto
Frameborder- attribute specifies whether or not to display a border around a frame.
0-border off,1-border on
The noresize attribute specifies that a frame cannot be resized by the user.
The marginwidth attribute specifies the width between the content and the left and right
sides of the frame, in pixels.
The marginheight attribute specifies the height between the content and the top and
bottom of the frame, in pixels.
The name attribute specifies the name of a frame.
The name attribute of the frame element is used to reference the element in a JavaScript,
or to act as a target for a link.