WT Module1
WT Module1
XHTML
Prepared By,
Ashji S Raj
AP, CSE,AJCE
AJCE/2014/WT
Web languages / technologies
AJCE/2014/WT
Origins and Evolution of HTML
HTML was defined with SGML[Std. Generalized Markup
Language]
Describes the content and structure of information on a web
page / HTML document
Original intent of HTML: General layout of documents that
could be displayed by a wide variety of computers
HTML stands for Hyper Text Markup Language
A markup language is a set of markup tags
The tags describe document content
HTML documents contain HTML tags and plain text
HTML versions: HTML 4, HTML 5
XHTML 1.0, XHTML 1.1
AJCE/2014/WT
Reasons to use XHTML, rather than HTML
AJCE/2014/WT
Basic Syntax
AJCE/2014/WT
Basic Syntax (Cont…)
If a tag has attributes, they appear between its name and the
right bracket of the opening tag
- <a href="default.htm"> this is a link </a>
AJCE/2014/WT
HTML Document Example
<!DOCTYPE html>
<html> <! -- defines the whole HTML document -- >
<head>
information about the page
</head>
<body> <! -- defines the body of the HTML doc. -- >
page contents
</body>
</html>
The header describes the page and the body contains the page's
contents
An HTML page is saved into a file ending with extension .html
AJCE/2014/WT
XHTML Document Structure
AJCE/2014/WT
XHTML Elements
AJCE/2014/WT
XHTML Attributes
AJCE/2014/WT
Basic Text Markup
AJCE/2014/WT
Paragraph
AJCE/2014/WT
Example
AJCE/2014/WT
Line Breaks
Use the <br> tag if you want a line break (a new line)
without starting a new paragraph:
The <br> element is an empty HTML element. It has
no end tag.
AJCE/2014/WT
Preserving Whitespace
AJCE/2014/WT
Headings
AJCE/2014/WT
Block Quotations
AJCE/2014/WT
Font Styles and sizes [Formatting Tags]
AJCE/2014/WT
Example: text formatting tags
AJCE/2014/W
T
Character Entities
These are special characters needed in a document but cannot be
typed as themselves. These special characters are defined as entities.
An entity in a document is replaced by its associated character by the
browser.
Char. Entity Meaning
& & Ampersand
< < Less than
> > Greater than
" " Double quote
' ' Single quote
¼ ¼ One quarter
½ ½ One half
¾ ¾ Three quarters
° Degree
(space) Non-breaking space
AJCE/2014/WT
Horizontal Rules
AJCE/2014/WT
The meta Element
AJCE/2014/WT
Block and inline elements
AJCE/2014/WT
IMAGES
AJCE/2014/WT
Example : image
AJCE/2014/WT
Image - Formats:
AJCE/2014/WT
XHTML Document Validation
AJCE/2014/WT
Hypertext Links
AJCE/2014/WT
Targets within Documents
If the target is not at the beginning of the document, the target spot
must be marked
Target labels can be defined in many different tags with the id
attribute, as in <a id = "baskets"> Baskets </a>
The link to an id must be preceded by a pound sign (#); If the id is in
the same document, this target could be
<a href = "#baskets"> What about baskets? </a>
If the target is in a different document, the document reference must
be included <a href = "myAd.html#baskets”> Baskets </a>
Style note: a link should blend in with the surrounding text, so
reading it without taking the link should not be made less pleasant
Links can have images:
<a href = "c210data.html">
<img src = "smallplane.jpg" alt = "Small picture of an airplane" />
</a>
AJCE/2014/WT
Lists
AJCE/2014/WT
Cont…
Ordered lists
The list is the content of the <ol> tag
Each item in the display is preceded by a sequence value
AJCE/2014/WT
Cont…
Nested lists
Any type list can be nested inside any type list
their definitions
List is the content of the <dl> tag
AJCE/2014/WT
Example
AJCE/2014/WT
Tables
AJCE/2014/WT
Tables cont…
AJCE/2014/WT
Tables cont…
AJCE/2014/WT
Tables cont…
AJCE/2014/WT
Table sections
AJCE/2014/WT
Forms
AJCE/2014/WT
Forms Cont…
AJCE/2014/WT
Form- Controls
Example
<form action=“ ” >
<input type = "text" name = "Phone“ size = "12“
maxlength=“25” />
</form>
Widgets should be placed in label elements
<form>
<label> <input type = "text” name = "phone" />
Phone:</label>
</form>
2. Password – just like text except asterisks are displayed,
rather than the input characters
<label> <input type = “password” name = “pwd" />
PWD:</label>
AJCE/2014/WT
Form- Controls
3. Checkboxes - to collect multiple choice input
Every checkbox requires a value attribute, which is the
widget’s value in the form data when the checkbox is
‘checked’
A checkbox button doesn’t contribute to the form if it is off
To initialize a checkbox to ‘checked’, the checked attribute
must be set to "checked” .By default, no checkbox is initially
‘checked’
Every checkbox requires a name attribute and value attribute
in its <input> tag. Name identifies the button and value is
its value.
Checkbox elements should also appear in label elements.
AJCE/2014/WT
Form- Controls
AJCE/2014/WT
Form- Controls
AJCE/2014/WT
Form- Controls
AJCE/2014/WT
Form- Controls
AJCE/2014/WT
Form- Controls
AJCE/2014/WT
Form- Controls
AJCE/2014/WT
Frames Cont …
AJCE/2014/WT
Syntactic Differences between HTML & XHTML
Property HTML XHTML
Tags and attributes are Case insensitive Tags and attributes must be in lower case
Case sensitivity <FORM> <Form>
It can be omitted if the processing agents can All the elements must have closing tags
infer their presents eg:<p> first paragraph … <input type=”text”
Closing tags <p> second paragraph … name=”address”></input>
Or <input type=”text” name=”address” / >
Some attribute values are implicit; they need Explicitly state the default value.
not be explicitly stated <table border=”border”>
Explicit attribute values
<table border>
Allows the use of both id and name attributes Use of id attribute is encouraged
id and name attributes & name is discouraged
Nesting rules are not strictly enforced. Nesting rules are strictly enforced.
Eg: An anchor element cannot contain another Syntactic rules are checked by the W3C
Element nesting
<a> and <form> element cannot contain validation software.
another form element
AJCE/2014/WT
Cascading Style Sheets [CSS]
AJCE/2014/W
T
Cascading Style Sheets
AJCE/2014/WT
Levels of Style Sheets
AJCE/2014/WT
Style Specification Formats
AJCE/2014/WT
Format for Document-level
AJCE/2014/WT
Form of the rules:
selector {list of property/values}
Each property/value pair has the form: property: value
Pairs are separated by semicolons
If property is given more than one value, separate them by
spaces/commas
Selector { property_1:value_1; property_2:value_2}
AJCE/2014/WT
External style sheets
AJCE/2014/WT
Selector Forms
h1{font-size:10px;}
h2, h3 {font-size:10px }
AJCE/2014/WT
Class Selectors
AJCE/2014/WT
Generic Selectors
AJCE/2014/WT
id Selectors
AJCE/2014/WT
Universal Selector & Pseudo Classes
Universal Selector
Denoted by asterisk(*) and applies its style to all elements in
the document
* {color:red}
Makes all elements in the document red.
Pseudo Classes
Pseudo classes are styles that apply when something
happens, rather than because the target element simply exists
Names begin with colons
hover classes apply when the mouse cursor is over the
element
focus classes apply when an element has focus
AJCE/2014/WT
Pseudo Classes example
AJCE/2014/WT
Property Value
Colors [3-ways]
Color name {red,blue}
rgb(n1, n2, n3) [rgb(176, 200,224)
Numbers can be decimal or percentages
Hex form: #XXXXXX [6-digit] [#43AF00]
font-family
This property is used to specify list of font names -
browser uses the first in the list it has
font-family: Arial, Helvetica, Courier
Generic fonts: serif, sans-serif, cursive, fantasy, and
monospace (defined in CSS)
Each Browser has a specific font for each of these specific
names font-family: Arial, Helvetica, Courier, serif
AJCE/2014/WT
Font Properties (continued)
font
This property is used for specifying a list of font
properties [ eg: font: bolder 14pt Arial Helvetica]
Specifies font weight should be bold, font size should be 14pt,&
either Arial / Helvetica font should be used.
Order in which the property values are given is important.
Order must be: font style, font variant font weight, font size,
font name(s)
The text-decoration property
Specifies some special features of text
line-through, overline, underline, none
AJCE/2014/WT
Colors
AJCE/2014/WT
Colors (continued)
2. There is a much larger set, the WEB PALETTE
216 colors . These colors are displayed by Windows and Macintosh
based browsers
Use hex color values of 00, 33, 66, 99, CC, and FF
3. Any one of 16 million different colors
The color property specifies the foreground color of elements
<style type = “text/css”>
th.red {color: red}
</style>
<table border = "5">
<tr>
<th class = "red"> Apple </th>
</tr>
</table>
The background-color property specifies the back ground color of
AJCE/2014/WT
elements
List properties
Property_name : list-style-type
Unordered lists
Bullet can be a disc (default), a square, or a circle
Set it on either the <ul> or <li> tag
On <ul>, it applies to list items
<h3> Some Common Single-Engine Aircraft </h3>
<ul style = "list-style-type: square">
<li> Cessna Skyhawk </li>
<li> Beechcraft Bonanza </li>
<li> Piper Cherokee </li>
</ul>
On <li>, list-style-type applies to just that item
AJCE/2014/WT
List properties (continued)
<h3> Some Common Single-Engine Aircraft </h3>
<ul>
<li style = "list-style-type: disc">
Cessna Skyhawk </li>
<li style = "list-style-type: square">
Beechcraft Bonanza </li>
<li style = "list-style-type: circle">
Piper Cherokee </li>
</ul>
AJCE/2014/WT
List properties (continued)
AJCE/2014/WT
Alignment of Text
AJCE/2014/WT
Alignment of Text
text-indent
Eg: <style type = “text/css”>
p.indent {text-indent: 0.5in}
</style>
. . .
<p class=indent>
this paragraph shows indentation
</p>
text-align
float
<style type = “text/css”>
p {text-align: left}
img {float: right}
</style>
AJCE/2014/WT
The Box Model
AJCE/2014/WT
The Box Model
AJCE/2014/WT
Background Images
AJCE/2014/WT
The <span> and <div> tags
AJCE/2014/WT
The <span> and <div> tags (continued)
AJCE/2014/WT
The <span> and <div> tags (continued)
sheets
Within the same level there can be conflicts
A tag may be used twice as a selector
3. General selectors
4. Universal Selectors