Top Banner
By Angelina Quansah
98

XHTML & CSS

Jan 01, 2016

Download

Documents

Anthony Hopkins

XHTML & CSS. By Angelina Quansah. XHTML & CSS. Definition Brief History XHTML CSS. Definition of XHTML. E X tensible H yper T ext M arkup L anguage A reformation of HTML in XML instead of SGML - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: XHTML & CSS

By Angelina Quansah

Page 2: XHTML & CSS

Definition Brief History XHTML CSS

Page 3: XHTML & CSS

EXtensible HyperText Markup Language A reformation of HTML in XML instead of SGML XML was designed to structure data

HTML was designed to display data.

Page 4: XHTML & CSS

Cascading Style Sheet A simple mechanism of adding style to a web

document

Separates presentation from content of documents

Page 5: XHTML & CSS

HTML

Page 6: XHTML & CSS

Tim Berners-Lee invented the Web in 1989 and HTML in 1992 at CERN.

(The European Laboratory for Particle Physics in Geneva, Switzerland)

- lots of people, organizations and companies joined in its

development. Dave Raggett from Hewlett-Packard's Labs in Bristol, England got

involved

- It grew from HTML 1.0 to HTML 2.0, HTML 3.0 . . .

Page 7: XHTML & CSS

- problems arose because lots of browsers added their own syntax and the language became ill-defined.

- w3 consortium was formed in 1994 to standardize the language.

- HTML 3.2 was introduced then HTML 4.0

Page 8: XHTML & CSS

HTML - is based on SGML by ISO. (Standard Generalized Mark Up Language by International Organization

for Standardization)

Examples of SGML elements in HTML are as

follows: <P> - paragraphs <H1> to <H6> - headings <OL> - ordered list <UL> - unordered list <LI> - list

Page 9: XHTML & CSS

HTML - is embedded into text to add formatting and link information.

HTML elements begins with an open tag and

ends with a closing tag. Examples: <h1> This is a heading </h1>

<p> This is a sentence </p>

<html> This is an html document</html>

Page 10: XHTML & CSS

HTML documents are divided into two sections:

- the header contains the introductory information like titles

<head> This is the heading </head>

- the body contains the main information <body> This is the main information</body>

Titles add to the search ability of the page and identifies the page when users add to their favorites

Page 11: XHTML & CSS
Page 12: XHTML & CSS

The are well-formed cleaner versions of HTML enforcing the following:

-All tags are paired - All elements and attributes must be in lower case only - All attributes are quoted - All attributes are presented as name = “value” pairs - XHTML elements must be properly nested

The strengths of HTML and XML were combined to bring sanity to the mark up language

Page 13: XHTML & CSS

Tags Meaning

<h1> …. </h1> to <h6>….</h6>

Defines header 1 to header 6

<b> ….</b> Defines bold text

<i> ….</i> Defines italic text

<u> ….</u> Defines underlined text

<em> ….</em> Defines emphasized text 

<sub> ….</sub> Defines subscripted text

<sup> ….</sup> Defines superscripted text

<blockquote > ….</blockquote> Defines a long quotation

<small>….</small> Defines small text

<pre> …. </pre> Defines preformatted text

<strike> ….</strike> Defines strikethrough text

<strong> ….</strong> Defines strong text

<font> ….</font> Defines text font, size, and color

<tt>….</tt> Defines teletype text

Page 14: XHTML & CSS

Tags Meaning

<dd> …. </dd> Defines a definition description

<dl> ….</dl> Defines a definition list

<dt> ….</dt> Defines a definition term

<ul> ….</ul> Defines an unordered list

<ol> ….</ol> Defines an ordered list

<li> ….</li> Defines a list item

<table> ….</table> Defines a table

<tbody > ….</tbody> Defines a table body

<tfoot>….</tfoot> Defines a table footer

<thead> …. </thead> Defines a table header

<td> ….</td> Defines a table cell

<th> ….</th> Defines a table header

<tr> ….</tr> Defines a table row

Page 15: XHTML & CSS

XHTML elements with no content are empty tags elements.

Examples: <br /> - for break in lines

<hr /> - for horizontal rule

XHTML documents have one root <html>……..</html>

Page 16: XHTML & CSS

root

Page 17: XHTML & CSS

XHTML elements may have attributes - attributes give additional information about the element - attributes are specified as name = “value” pairs

Examples: <h1 align="center">This is a heading </h1>

<a href="http://www.utpa.edu">UTPA</a>

- The element <a> (anchor) and href attribute is Tim’s own invention for linking web pages

Page 18: XHTML & CSS
Page 19: XHTML & CSS

A link to the specified URL

Initiates e-mail message

Page 20: XHTML & CSS

The <img> element with attribute src is for adding images to web page

Like the <hr /> is has no closing tag.

<img src = “textbook.gif” />

Page 21: XHTML & CSS

An alt attribute must be quoted with the img element

- This indicates an alternative text to display if image cannot be rendered.

<img src = “textbook.gif” alt = “E-commerce Textbook” />

Page 22: XHTML & CSS

The width and height may be quoted in pixels - The browser uses the images actual size if note quoted.

<img src = “textbook.gif” width = “92 height = “120”alt = “E-commerce Textbook” />

Page 23: XHTML & CSS
Page 24: XHTML & CSS

Table are composed of data cells and organized into rows and split into three sections

- head <thead></thead> - table titles - column headers

- body <tbody></tbody> - primary table data

- foot <tfoot></tfoot> - calculation results - foot notes

Page 25: XHTML & CSS

Table are composed of data cells and organized into rows and split into three sections

- data cells are defined within <td></td>

- table rows are defined within <tr></tr>

- header cells are defined within <th></th>

Attribute colspan and rowspan can be used to merge data cells

- value of the attribute specifies the rows or column to be merged

Page 26: XHTML & CSS

All are nested in the table element

comments

Page 27: XHTML & CSS

Merge columns

Merge rows

Page 28: XHTML & CSS

Definition list tags are nested within each other

<dt></dt> definition term and <dd></dd> definition description are nested within <dl></dl>

This list tags are nested within either the ordered list tags or unordered list tags.

<ol><li>ordered list</li></ol> <ul> <li>unordered list</li></ul>

Page 29: XHTML & CSS
Page 30: XHTML & CSS
Page 31: XHTML & CSS

WYSIWYG editor - what you see is what you get

Only the document’s content and structure appears in the XHTML document

- formatting are mostly specified with CSS

Page 32: XHTML & CSS

Comments begin with <!--- and end with --> - the browser ignores the text within

XHTML documents with syntax errors are not guaranteed to display properly.

XHTML documents can be validated with W3C's validator.

Page 33: XHTML & CSS

W3C provides a validation service for checking to check correct syntax

- files can be uploaded for validation using: validator.w3.org/file-upload.html

- files can be validated by specifying the url to the files location using: validator.w3.org

Page 34: XHTML & CSS

Forms unable users to enter information and send to server

Form is surrounded by the <form> tag which is specified as:

<form action = “url” method = “method” </form> - method is specified as either “get” or “post” get - url produced after submission includes information entered

post – does not return information entered

Page 35: XHTML & CSS

Input fields within the form are specified with input tags with different attributes

- text input - inserts a text box that allows user to enter data

- label element - provides information about the input element’s purpose

Page 36: XHTML & CSS

- size attribute - specifies the number of characters visible in the input element

- optional attribute - limits the number of characters input into a text box

- submit input - submits data entered to the web server for processing

- reset input - allows user to reset all form elements to their default values

Page 37: XHTML & CSS

- password - user input displayed at asterisks or bullets for security

- checkbox attribute - allows user to make group or single selection

- hidden - submits data entered to the web server for processing

- radio - allows user to select only one option at a time

Page 38: XHTML & CSS

- textarea element - inserts a multiline text box called text area into form

- number of rows is specified with row attribute

- number of columns with cols attribute

- select input - provides a drop down list of items

- the name element identifies the drop down list

- the option element adds items to the drop down list

Page 39: XHTML & CSS

checkboxradio

Page 40: XHTML & CSS
Page 41: XHTML & CSS
Page 42: XHTML & CSS

method = post

Page 43: XHTML & CSS

method = get

Page 44: XHTML & CSS

Meta Element has - name attribute identifies the type of meta element - content attribute - of a keyword of the meta element provide search engines with list

of words that describe the page

- of a description meta element provides a three to four line of a

site in a sentence form

Page 45: XHTML & CSS
Page 46: XHTML & CSS

Unlike the HTML, the XHTML document has three main parts

- The doctype declaration - The head - The body

Page 47: XHTML & CSS

doctype

head

body

Page 48: XHTML & CSS

There are three document type definitions (DTD)

- The strict - The transitional - The frameset

Page 49: XHTML & CSS

The strict <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

The strict DOCTYPE is used when the document is written in clean mark up language free of any presentational errors normally made in HTML

Page 50: XHTML & CSS

The transitional <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

The transitional DOCTYPE is used when document still has html presentational features.

Page 51: XHTML & CSS

The frameset <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

The frameset DOCTYPE is used if you want to use HTML Frames to split the web page into two or more frames.

Page 52: XHTML & CSS

Defines how to display XHTML documents and are saved in style sheets with extension css

mystyles.css

Style sheet allow style information to be specified in many ways

Attributes are inherited

Page 53: XHTML & CSS

CSS specifications are case sensitive and appear in the same format as

name: value; -> color: blue;

Style block elements have style attributes

defined in curly braces b {color: blue}

Multiple properties are separated with a semicolon

b {color: blue; font-family: arial}

Page 54: XHTML & CSS

CSS rule consist of two parts: - the selector is the element that receives the style

h1{color: blue}

- the declaration which has two parts

- the property “color” and value “blue”

Page 55: XHTML & CSS

Styles are mostly declared in the following tags: <div></div>

<span></span>

div is used as a block container like a paragraph

span is used within a block

Page 56: XHTML & CSS

Types of CSS - Inline CSS - Embedded Style Sheets - External Style Sheets

Page 57: XHTML & CSS

This allows the specification of a style in a single element

<b style = “color: blue”></b>

Page 58: XHTML & CSS
Page 59: XHTML & CSS

CSS styles of elements are specified in a style block in the header section of the document

All occurrence of the element inherit the style

Page 60: XHTML & CSS

style sheet

document

results

Page 61: XHTML & CSS

Most styles are inherited from parent elements

Styles defined for children overwrite parent specifications

Page 62: XHTML & CSS

Classes can be specified as subtags

Classes can be used several times in the same document

Classes allow authors to apply rule to a particular element within the document

Page 63: XHTML & CSS

The class declaration in the style block is preceded with a period

.camera { font-size: 120%;color: #ff6666;} <span class =“camera">Sony</span>

Page 64: XHTML & CSS
Page 65: XHTML & CSS

Relative length measurements: - px (size depends on screen resolution)

- em (usually the size of a font’s uppercase) - ex (usually the size of a font’s lowercase) - percentage (of font’s default size)

Page 66: XHTML & CSS

Absolute length measurements: - inches

- centimeters - millimeters - points

Page 67: XHTML & CSS

Its advisable to use relative length measurement for text to ensure readability on all user agents

Page 68: XHTML & CSS

Separate documents containing only CSS rules

Separate web pages in separate website can all use the same style

Several website can be modifies with the edit of a single style sheet

Page 69: XHTML & CSS

The link element is used to reference a separate style sheet

<link type = “text/css” href =“mystyles.css” />

where mystyles.css is a separate style sheet store in the same directory on the same server.

Page 70: XHTML & CSS

A url can also be used to reference style sheets <link rel = “text/css”

href =“http://www.cs.panam.edu/library/mystyles.css” />

Page 71: XHTML & CSS
Page 72: XHTML & CSS

CSS has control over lists ul { list-style-type: disc; } ol { list-style-type: lower-roman; }

CSS values for unordered lists are - disc - circle - square

Page 73: XHTML & CSS

Can reference a bullet from a graphic file form a server.

ul { list-style-image: url(diamond.jpg) line-height: 1.5 }

There are many possibilities and values for the ordered lists

decimal - 1,2,3…lower-roman - i, ii, iii…upper-roman - I, II, III…

Page 74: XHTML & CSS

Text Formatting

Other properties

Page 75: XHTML & CSS

- Bold text - specified as font-weight - normal - lighter - bold - bolder

It can also be specified in increments of 100, from 100 to 900

<div style = “font-weight:bold”>

Page 76: XHTML & CSS

- italics - specified as font-style - normal - italics - oblique

<div style = “font-style:italics”>

Page 77: XHTML & CSS

typeface - specified as font-family - serif - san serif - cursive - fantasy

<div style = “font-family:arial”>

Page 78: XHTML & CSS

size - specified as font-size - xx small, xx large - x small, x large - small, medium, large

Page 79: XHTML & CSS

text color - specified as color - specified either in name or hexadecimal values

- its two hexadecimal digit representing red, green and

blue respectively where 00 is the least and ff is the most #RRGGBB as 009900

Page 80: XHTML & CSS

Text alignment - specified as text-align - left - right - center - justify

<div style = “font-family:arial”>

Page 81: XHTML & CSS

Text decoration - specified as text-decoration - underline - overline - line-through

h1{text-decoration overline}

Page 82: XHTML & CSS

text transformation -specified as text-transform - capitalize - uppercase - lowercase - none h1{text-transform: capitalize}

Page 83: XHTML & CSS

Each element has the is surrounded by - margin - is the distance between the elements edge and any outside text - margin-top, margin-right, margin-left and margin-bottom

- padding - is the distance between an elements and the edge of the element. - padding-top, padding-right, padding-left and padding-bottom

Page 84: XHTML & CSS

border - border-width

May be set to any of the CSS lengths or to the predefined value of thin, medium or thick

- border-color

sets the color used for the border

- border-style

Options are: none, hidden, dotted, dashed, solid, double, groove, ridge, inset and outset

Page 85: XHTML & CSS
Page 86: XHTML & CSS

Positioning - absolute position have greater control on where on the page an element resides - absolute positioning place the element according to specifications on the top, left, right or bottom of its parent element

Page 87: XHTML & CSS

Positioning - relative positioning places an element relative to its normal position. - overflow property is used when content of element exceeds specified area. - associated attributes are for overflow are visible, hidden, scroll, inherit or auto

Page 88: XHTML & CSS

Backgrounds - background-image indicates the url of the image background-image: url(textbook.jpg)

- background-position places image on the page with top, bottom, center, left and right as desired. background-position: bottom right

Page 89: XHTML & CSS

Backgrounds - background-repeat control titling of the background image. background-repeat: no-repeat

- setting background repeat as repeat tiles the image vertically or horizontally. - repeat-x for horizontal - repeat-y for vertical

Page 90: XHTML & CSS

Backgrounds - background-attachment fixes the image in the position specified and scrolling the browser cannot affect it

background-attachment: fixed

Page 91: XHTML & CSS

The image is fixed so scrolling does not move it

Page 92: XHTML & CSS

Float property - an element can be floated to the right or left using the float property.

Page 93: XHTML & CSS
Page 94: XHTML & CSS

Media types - a programmer can specify different style rules for

different media types in the same style sheet.

Page 95: XHTML & CSS

Indicates that font should be 14px on screen

Indicates that font should be 10px when printed

Indicates that they should both be bold

Page 96: XHTML & CSS

Media Type Description

all Used for all media type devices

aural Used for speech and sound synthesizers

braille Used for braille tactile feedback devices

embossed Used for paged braille printers

handheld Used for small or handheld devices

print Used for printers

projection Used for projected presentations, like slides

screen Used for computer screens

tv Used for television-type devices

Page 97: XHTML & CSS

Pages load faster- Less code means faster download times.

Easy maintenance - To change the style of an element, you only have to

make an edit in one place.

Page 98: XHTML & CSS

www.w3schools.com www.intuitive.com www.w3.org/People/Raggett/book4/ch02.html

Internet & World Wide Web, How to Program - Deitel, Deitel, & Goldberg

Creating Cool Web Sties with HTML,XHTML and CSS - Dave Taylor