HTML and CSS
HTML and CSS
HTML tags are keywords (tag names) surrounded by angle brackets like
<html>.
They are not case sensitive : <HEAD> , <head> , <hEaD> are same.
The first tag in a pair is the start tag, the second tag is the end tag.
The end tag is written like the start tag, with a forward slash before the
tag name.
Start and end tags are also called opening tags and closing tags.
Syntax: <tagname>content</tagname>
<html>
<head>
<title> First HTML Document </title>
</head>
<body>
<h1>This a heading</h1>
<p>A sample paragraph</p>
</body>
</html>
To learn HTML we can use text editors like
Notepad (PC) or TextEdit (Mac).
Adobe Dreamweaver.
<b> ….</b>
<i>……</i>
<sub>….</sub>
<sup>…..</sup>
<pre>….</pre>
& < > "
A hyperlink (or link) is a word, group of words, or
image that you can click on to jump to another
document.
<a href="http://www.googlescholar.com/"
target="_blank">Visit My Favorite
website!</a>
The most common HTML lists are ordered
and unordered lists:
An ordered list:
1.The first list item
2.The second list item
3.The third list item
An unordered list:
. List item
. List item
. List item
An unordered list starts with the <ul> tag. Each
list item starts with the <li> tag.
</tr>
</table>
</body>
</html>
<h4>Cell that spans two rows:</h4>
<table border="1">
<tr>
<th>First Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>555 77 854</td>
</tr>
<tr>
<td>555 77 855</td>
</tr>
</table>
Tag Description
<h4>Without cellspacing:</h4>
<table border="1">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With cellspacing="0":</h4>
<table border="1" cellspacing="0">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
In HTML, images are defined with the <img>
tag.
The <img> tag is empty, which means that it
contains attributes only, and has no closing
tag.
To display an image on a page, you need to
use the src attribute. Src stands for "source".
The value of the src attribute is the URL of the
image you want to display.
<img src="url" alt="some_text ">
HTML frames are used to divide your browser
window into multiple sections where each
section can load a separate HTML document.
A collection of frames in the browser window
is known as a frameset.
The window is divided into frames in a similar
way the tables are organized: into rows and
columns.
To use frames on a page we use <frameset>
tag instead of <body> tag.
The <frameset> tag defines how to divide the
window into frames.
The rows attribute of <frameset> tag defines
horizontal frames and cols attribute defines
vertical frames.
Each frame is indicated by <frame> tag and it
defines which HTML document shall open
into the frame.
HTML Horizontal Frames
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows="10%,80%,10%">
<frame name="top“ src="/html/top_frame.htm" />
<frame name="main" src="/html/main_frame.htm" />
<frame name="bottom" src=“/html/bottom_frame.htm" />
<body> Your browser does not support frames. </body>
</frameset>
</html>
<html>
<head>
<title>HTML Iframes</title>
</head>
<body> <p>Document content goes here...</p>
<iframe src="/html/menu.htm" width="555" height="200">
Sorry your browser does not support inline frames.
</iframe>
<p>Document content also go here...</p>
</body>
</html>
HTML forms are used to pass data to a server.
<form>
First name: <input type="text"
name="firstname"><br>
Last name: <input type="text"
name="lastname">
</form>
<input type="password"> defines a password
field:
<form>
Password: <input type="password"
name="pwd">
</form>
<input type="radio"> defines a radio button.
Radio buttons let a user select ONLY ONE of a
limited number of choices:
<form>
<input type="radio" name="sex"
value="male">Male<br>
<input type="radio" name="sex"
value="female">Female
</form>
<input type="checkbox"> defines a
checkbox.
Checkboxes let a user select ZERO or MORE
options of a limited number of choices.
<form>
<input type="checkbox" name="vehicle"
value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle"
value="Car">I have a car
</form>
<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.asp" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
<html>
<body>
<form action="">
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
</body>
</html>
<html>
<body>
<form action="">
<input type="button" value="Hello world!">
</form>
</body>
</html>
In HTML there is the capability to separate
presentation and content.
<body>
</body>
</html>
Inline Stylesheets: Style within the Body section.
/*This is a comment*/
p
{
text-align:center;
/*This is another comment*/
color:black;
font-family:arial;
}
In addition to setting a style for a HTML
element, CSS allows you to specify your own
selectors called "id" and "class".
<html>
<head>
<style>
#hello
{
text-align:center;
color:red;
}
</style>
</head>
<body>
<p id="hello">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>
The class selector is used to specify a style
for a group of elements.
Selector.classname {property:value;
property:value}
<selector class=classname>
H1.fred
{
Color:blue;
Background-color:red;
Font-family:”Book Antiqua”,Times,serif;
border:thin groove yellow;
}
Margin:length|percantage|auto {1,4}
Border-width:thin|thick|medium|length {1,4}
Padding:length|percantage {1,4}
Border-color:value {1,4}
Border-
style:none|dotted|dashed|solid|double|groov
e|ridge {1,4}
Width:length|percantage|auto
Height:length|auto
The designers use images as the backgrounds of
their pages and then place further images and text
over them.
We can place text items and images on top of each
other in multiple layers.
Z-index:n
Position:absolute |relative
Left:n
Top:n
Width:n
Height:n
<html>
<head>
<title> LAYERING TEXT</title>
</head>
<body>
<h1>Layering Text </h1>
<div style=“z-index:2; left:50px;top:250px;position:absolute;font-size:36pt;border:thin-groove;”>
<p>This is the higher layer </p>
</div>
<hr>
</body>
</html>