Foreword

Previous classes have consisted of "Exploring Web Design", which covered a lot of general information regarding the history of the internet, the browser wars, and graphics design along with their design elements and principles. this introductory class gave insight on the underlying fundamentals of design and gave insight to understanding what it is that you see when browsing sites on the internet.

The second installment came in the form of "HTML 101", a class that introduced the basics of the hypertext markup language and how it can be utilized to create simple webpages through working examples. At that time Cascading style Sheets where not necessarily treated as an afterthought but it was planned to set it aside for another class, so to not overwhelm the student. Unfortunately, in the meanwhile, CSS had evolved to another standard (CSS3) along with many other developments. Although the information served its purpose it now seems almost antiquated in the advent of HTML 5 and Responsive Design. Nevertheless, it still provides the necessary tools to understanding the fundamental mechanics of HTML itself, which will then lend to a greater appreciation for Cascading style Sheets (CSS).

This class will bridge the gap between the last installment, which left off with HTML standard 3.2/4.01 and start with a brief review of key points of the older standard along with the introduction of Cascading Style Sheets. The main focus of this class will be on the HTML5 standard along with CSS3 and Responsive Design. JavaScript along with multimedia, transitions and other elements integral to interactive and dynamic design will also be covered.

If you paid attention in the previous installments you will be alright but a warning to the weary this class is not recommended for those who are not yet proficient with HTML or are not ready to commit to studying this subject. There will be a lot of material covered in a classroom setting but you will also have to scrutinize and digest a lot of it on your own time.

One unique aspect of the lessons in HTML 201 is the use of the W3 Schools' developed "Try-it Editor". This tool will allow the student to virtually see the result of assembled code on the fly without going through the motions of creating files in a text editor, saving it and then opening it in a browser to view it (as was done in HTML 101). Therefore it will be imperative for you to make yourself familiar with document structure and and use of certain elements such as inline styles and inline scripts. Lack of the aforementioned can and will create situations in which you will attempt to enter code into the "Try-it Editor" and clicking on "View Results" will get you nothing but a blank screen or gibberish while you wait and expect for something else to happen.

The greater part of the material for this class was provided by "W3 Schools.com", a provider of online certification programs and self proclaimed "World's Largest Web Developer Site". Adaption of this material for this environment required the localization of all of the external reference material and interactive examples. There is still quite a lot of material that had to be left on the table because it could not be made accessible within the constraints of reasonable time and effort. Nevertheless, the information that is provided is current and up to date and will allow you a definitive glimpse into the complexities of modern web design.


By J.E. McCoy

Powered By:

 










 







HTML Editors


Write HTML Using Notepad or TextEdit

HTML can be edited by using professional HTML editors like:

However, for learning HTML it is recommended that simple a text editor like Notepad (PC) or TextEdit (Mac) be used.

It has been proven that using a simple text editor is the best way to learn HTML.

Follow the 4 steps below to create your first web page with Notepad.


Step 1: Open Notepad

To open Notepad in Windows:

Click Start (bottom left on your screen). Click All Programs. Click Accessories. Click Notepad.

To open Notepad in Windows 8 or later:

Open the Start Screen (the window symbol at the bottom left on your screen). Type Notepad.


Step 2: Write Some HTML

Write or copy some HTML into Notepad.

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>

Notepad


Step 3: Save the HTML Page

Save the file on your computer.

Select File > Save as in the Notepad menu.

Name the file "index.html" or any other name ending with html or htm.

UTF-8 is the preferred encoding for HTML files.

ANSI encoding covers US and Western European characters only.

View in browser

Note You can use either .htm or .html as file extension. There is no difference, it is up to you.

Step 4: View HTML Page in Your browser

Open the saved HTML file in your favorite browser. The result will look much like this:

View in browser

Note To open a file in a browser, double click on the file, or right-click, and choose open with.

 







HTML Basic Examples


Don't worry if these examples use tags you have not learned.

You will learn about them in the near future.


HTML Documents

All HTML documents must start with a document-type-declaration (DTD): <!DOCTYPE html>.

The HTML document itself begins with <html> and ends with </html>.

The visible part of the HTML document is between <body> and </body>.

Example

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>
Try it Yourself »

HTML Headings

HTML headings are defined with the <h1> to <h6> tags:

Example

<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
Try it yourself »

HTML Paragraphs

HTML paragraphs are defined with the <p> tag:

Example

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
Try it yourself »

HTML links

HTML links are defined with the <a> tag which designates an anchor:

Example

<a href="http://www.w3schools.com">This is a link</a>

The link's actual destination is specified in the hyperlink reference href attribute

Attributes are used to provide additional information about HTML elements.


HTML Images

HTML images are defined with the <img> tag.

The source file (src), alternative text (alt), and size (width and height) are provided as attributes:

Example

<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
Note You will learn more about attributes as you continue.

 







HTML Text Formatting Elements


Text Formatting

This text is bold

This text is italic

This is superscript

HTML Formatting Elements

HTML also defines special elements, for defining text with a special meaning.

HTML uses elements like <b> and <i> for formatting output, like bold or italic text.

Formatting elements were designed to display special types of text:


HTML Bold and Strong Formatting

The HTML <b> element defines bold text, without any extra importance.

Example

<p>This text is normal.</p>

<p><b>This text is bold</b>.</p>
Try it Yourself »

The HTML <strong> element defines strong text, with added semantic "strong" importance.

Example

<p>This text is normal.</p>

<p><strong>This text is strong</strong>.</p>
Try it Yourself »

HTML Italic and Emphasized Formatting

The HTML <i> element defines italic text, without any extra importance.

Example

<p>This text is normal.</p>

<p><i>This text is italic</i>.</p>
Try it Yourself »

The HTML <em> element defines emphasized text, with added semantic importance.

Example

<p>This text is normal.</p>

<p><em>This text is emphasized</em>.</p>
Try it Yourself »
Note Browsers display <strong> as <b>, and <em> as <i>. However, there is a difference in the meaning of these tags:<b> and <i> defines bold and italic text, but <strong> and <em> means that the text is "important".

HTML Small Formatting

The HTML <small> element defines small text:

Example

<h2>HTML <small>Small</small> Formatting</h2>
Try it Yourself »

HTML Marked Formatting

The HTML <mark> element defines marked or highlighted text:

Example

<h2>HTML <mark>Marked</mark> Formatting</h2>
Try it Yourself »

HTML Deleted Formatting

The HTML <del> element defines deleted (removed) text.

Example

<p>My favorite color is <del>blue</del> red.</p>
Try it Yourself »

HTML Inserted Formatting

The HTML <ins> element defines inserted (added) text.

Example

<p>My favorite <ins>color</ins> is red.</p>
Try it Yourself »

HTML Subscript Formatting

The HTML <sub> element defines subscripted text.

Example

<p>This is <sub>subscripted</sub> text.</p>
Try it Yourself »

HTML Superscript Formatting

The HTML <sup> element defines superscripted text.

Example

<p>This is <sup>superscripted</sup> text.</p>
Try it Yourself »

HTML Text Formatting Elements

Tag Description
<b> Defines bold text
<em> Defines emphasized text 
<i> Defines italic text
<small> Defines smaller text
<strong> Defines important text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
<mark> Defines marked/highlighted text

 







HTML styles - CSS



CSS = styles and Colors

Manipulate Text
Colors,  Boxes

Example

<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:lightgray}
h1   {color:blue}
p    {color:green}
</style>
</head>
<body>

<h1>this is a heading</h1>
<p>this is a paragraph.</p>

</body>
</html>
Try it yourself »

Styling HTML with CSS

CSS stands for Cascading Style Sheets

Styling can be added to HTML elements in 3 ways:

The most common way to add styling, is to keep the styles in separate CSS files. But, in this tutorial, we use internal styling, because it is easier to demonstrate, and easier for you to try it yourself.

Note You can learn much more about CSS in our CSS Tutorial.

CSS Syntax

CSS styling has the following syntax:

element { property:value; property:value }

The element is an HTML element name. The property is a CSS property. The value is a CSS value.

Multiple styles are separated with semicolon.


Inline Styling (Inline CSS)

Inline styling is useful for applying a unique style to a single HTML element:

Inline styling uses the style attribute.

this inline styling changes the text color of a single heading:

Example

<h1 style="color:blue">this is a Blue Heading</h1>
Try it yourself »

Internal Styling (Internal CSS)

An internal style sheet can be used to define a common style for all HTML elements on a page.

Internal styling is defined in the <head> section of an HTML page, using a <style> element:

Example

<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:lightgrey}
h1   {color:blue}
p    {color:green}
</style>
</head>
<body>

<h1>this is a heading</h1>
<p>this is a paragraph.</p>

</body>
</html>
Try it yourself »

External Styling (External CSS)

External style sheet are ideal when the style is applied to many pages.

With external style sheets, you can change the look of an entire web site by changing one file.

External styles are defined in an external CSS file, and then linked to in the <head> section of an HTML page:

Example

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="styles.css">
</head>
<body>

<h1>this is a heading</h1>
<p>this is a paragraph.</p>

</body>
</html>
Not Available

CSS Fonts

The CSS color property defines the text color to be used for the HTML element.

The CSS font-family property defines the font to be used for the HTML element.

The CSS font-size property defines the text size to be used for the HTML element.

Example

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
    color:blue;
    font-family:verdana;
    font-size:300%;
}
p  {
    color:red;
    font-family:courier;
    font-size:160%;
}
</style>
</head>
<body>

<h1>this is a heading</h1>
<p>this is a paragraph.</p>

</body>
</html>
Try it yourself »

the CSS Box Model

Every HTML element has a box around it, even if you cannot see it.

The CSS border property defines a visible border around an HTML element:

NOTE: Make sure that you understand the proper document structure of an HTML page. The following example is a decleration that would be used in internal styling, intended for use in a style block. In order to use it here without just ending up with text appearing in the tryit Editor, you must enclose the example with <style>...</style> tags to create a style block and then actually use the element (<p>...</p>) you are intending to define in order to see the style applied.

Example

p {
    border:1px solid black;
}
Try it yourself »

The CSS padding property defines a padding (space) inside the border:

Example

p {
    border:1px solid black;
    padding:10px;
}
Try it yourself »

The CSS margin property defines a margin (space) outside the border:

Example

p {
    border:1px solid black;
    padding:10px;
    margin:30px;
}
Try it yourself »
Note the CSS examples above use px to define sizes in pixels.

the id Attribute

All the examples above use CSS to style HTML elements in a general way.

To define a special style for one special element, first add an id attribute to the element:

Example

<p id="p01">I am different</p>

Then define a different style for the (identified) element: (create a style block for this id)

Example

p#p01 {
    color:blue;
}
Try it yourself »

the class Attribute

To define a style for a special type (class) of elements, add a class attribute to the element:

Example

<p class="error">I am different</p>

Now you can define a different style for all elements with the specified class: (create a style block for this class)

Example

p.error {
    color:red;
}
Try it yourself »
Note Use id to address single elements. Use class to address groups of elements.

Deprecated Tags and Attributes in HTML5

In older HTML versions, several tags and attributes were used to style documents.

These tags and attributes are not supported in HTML5!

Avoid using the <font>, <center>, and <strike> elements.

Avoid using the color and bgcolor attributes.


Chapter Summary


HTML style Tags

Tag Description
<style> Defines style information for a document
<link> Defines a link between a document and an external resource

 







HTML Layouts


Websites often display content in multiple columns (like a magazine or newspaper).


City Gallery

London
Paris
Tokyo

London

London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.

Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.

Copyright © W3Schools.com

HTML Layout Using <div> Elements

Note The <div> element is often used as a layout tool, because it can easily be positioned with CSS.

This example uses four <div> elements to create a multiple column layout:

Example

<body>

<div id="header">
<h1>City Gallery</h1>
</div>

<div id="nav">
London<br>
Paris<br>
Tokyo
</div>

<div id="section">
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium. </p>
</div>

<div id="footer">
Copyright © W3Schools.com
</div>

</body>
Try it yourself »

The CSS:

<style>
#header {
   background-color:black;
   color:white;
   text-align:center;
   padding:5px;
}
#nav {
   line-height:30px;
   background-color:#eeeeee;
   height:300px;
   width:100px;
   float:left;
   padding:5px;
}
#section {
   width:350px;
   float:left;
   padding:10px;
}
#footer {
   background-color:black;
   color:white;
   clear:both;
   text-align:center;
   padding:5px;
}
</style>

To get the full effect of the layout example shown, combine the CSS style block with the HTML from above in the try-it editor.

Try it yourself »

Website Layout Using HTML5

HTML5 offers new semantic elements that define different parts of a web page:

HTML5 Semantic Elements
  • <header> - Defines a header for a document or a section
  • <nav> - Defines a container for navigation links
  • <section> - Defines a section in a document
  • <article> - Defines an independent self-contained article
  • <aside> - Defines content aside from the content (like a sidebar)
  • <footer> - Defines a footer for a document or a section
  • <details> - Defines additional details
  • <summary> - Defines a heading for the <details> element

This example uses <header>, <nav>, <section>, and <footer> to create a multiple column layout:

Example

<body>

<header>
<h1>City Gallery</h1>
</header>

<nav>
London<br>
Paris<br>
Tokyo
</nav>

<section>
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.</p>
</section>

<footer>
Copyright © W3Schools.com
</footer>

</body>
Try it yourself »

The CSS:

<style>
header {
    background-color:black;
    color:white;
    text-align:center;
    padding:5px;
}
nav {
    line-height:30px;
    background-color:#eeeeee;
    height:300px;
    width:100px;
    float:left;
    padding:5px;
}
section {
    width:350px;
    float:left;
    padding:10px;
}
footer {
    background-color:black;
    color:white;
    clear:both;
    text-align:center;
    padding:5px;
}
</style>
Note Note the difference in the way the divisions were defined between the traditional and the HTML5 examples.

HTML Layout Using Tables

Note The <table> element was not designed to be a layout tool.
The purpose of the <table> element is to display tabular data.

Layout can be achieved using the <table> element, because table elements can be styled with CSS:

Example

<body>

<table class="lamp">
<tr>
  <th>
    <img src="/images/alert.png" alt="Note" style="height:45px; width:45px">
  </th>
  <td>
    The table element was not designed to be a layout tool.
  </td>
</tr>
</table>

</body>
Try it yourself »

The CSS:

<style>
table.lamp {
    width:100%;
    border:1px solid #d4d4d4;
}
table.lamp th, td {
    padding:10px;
}
table.lamp th {
    width:40px;
}
</style>
Note Warning: Creating layout with tables is not wrong, but it is not recommended! Avoid tables for creating layout.

 







HTML iframes


An iframe is used to display a web page within a web page.





iframe Syntax

The syntax for adding an iframe is:

<iframe src="URL"></iframe>

The src attribute specifies the URL (web address) of the iframe page.


iframe - Set Height and Width

Use the height and width attributes to specify the size.

The attribute values are specified in pixels by default, but they can also be in percent (like "80%").

Example

<iframe src="demo_iframe.htm" width="400px" height="200px"> </iframe>
Try it yourself »

iframe - Remove the Border

By default, an iframe has a black border around it.

To remove the border, add the style attribute and use the CSS border property:

Example

<iframe src="demo_iframe.htm" width="400px" height="200px" style="border:none"></iframe>
Try it yourself »

With CSS, you can also change the size, style and color of the iframe's border:

Example

<iframe src="demo_iframe.htm" width="400px" height="200px" style="border:5px dotted red"></iframe>
Try it yourself »

Use iframe as a Target for a link

An iframe can be used as the target frame for a link.

The target attribute of the link must refer to the name attribute of the iframe:

Example

<iframe src="demo_iframe.htm" name="iframe_a"></iframe>
<p><a href="http://www.w3schools.com" target="iframe_a"> W3Schools.com</a></p>
Try it yourself »

HTML iframe Tag

Tag Description
<iframe> Defines an inline frame

 







HTML Head


The HTML <head> Element

The <head> element is a container for metadata (data about data).

HTML metadata is data about the HTML document. Metadata is not displayed.

Metadata typically define document title, styles, links, scripts, and other meta information.

The following tags describe metadata: <title>, <style>, <meta>, <link>, <script>, and <base>.


Omitting <html> and <body>?

In the HTML5 standard, the <html> tag, the <body> tag, and the <head> tag can be omitted.

The following code will validate as HTML5:

Example

<!DOCTYPE html>
<title>Page Title</title>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>
Note Omitting the <html> and <body> tags is not recommended since it has the potential of causing problems with compatibility and functionality.

The <html> element is the document root. It is the recommended place for specifying the page language:

<!DOCTYPE html>
<html lang="en-US">

Declaring a language is important for accessibility applications (screen readers) and search engines.

Omitting <html> and <body> can crash badly-written DOM/XML software.

Finally, omitting <body> can produce errors in older browsers (IE9).


Omitting <head>

In the HTML5 standard, the <head> tag can also be omitted.

By default, browsers will add all elements before <body>, to a default <head> element.

You can reduce the complexity of HTML, by omitting the <head> tag:

Example

<!DOCTYPE html>
<html>
<title>Page Title</title>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>
Note Omitting tags is unfamiliar to web developers, especially when the absence of them create a loss of designed functionality. The omission of tags is served best for laymen who produce sites that are not complex. Regardless it will still take time to be established as a guideline.

The HTML <title> Element

The <title> element defines the title of the document.

The <title> element is required in all HTML/XHTML documents.

The <title> element:

A simplified HTML document:

Example

<!DOCTYPE html>
<html>
<title>Page Title</title>

<body>
The content of the document......
</body>

</html>

The HTML <style> Element

The <style> element is used to define style information for an HTML document.

Inside the <style> element you specify how HTML elements should render in a browser:

Example

<style>
body {background-color:yellow;}
p {color:blue;}
</style>
Try it Yourself »

The HTML <link> Element

The <link> element defines the page relationship to an external resource.

The <link> element is most often used to link to style sheets:

Example

<link rel="stylesheet" href="mystyle.css">

The HTML <meta> Element

The <meta> element is used to specify page description, keywords, author, and other metadata.

Metadata is used by browsers (how to display content), by search engines (keywords), and other web services.

Define keywords for search engines:

<meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript">

Define a description of your web page:

<meta name="description" content="Free Web tutorials on HTML and CSS">

Define the character set used:

<meta charset="UTF-8">

Define the author of a page:

<meta name="author" content="Hege Refsnes">

Refresh document every 30 seconds:

<meta http-equiv="refresh" content="30">

Example of <meta> tags:

Example

<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="Hege Refsnes">
<meta charset="UTF-8">

The HTML <script> Element

The <script> element is used to define client-side JavaScripts.

The script below writes Hello JavaScript! into an HTML element with id="demo":

Example

<script>
function myFunction {
    document.getElementById("demo").innerHTML = "Hello JavaScript!";
}
</script>
Note You will find more information on the power of JavaScript as you progress thorough this material. To learn about JavaScript, visit the JavaScript Tutorial!

The HTML <base> Element

The <base> element specifies the base URL and base target for all relative URLs in a page:

Example

<base href="http://www.w3schools.com/images/" target="_blank">
Try it Yourself »

HTML head Elements

Tag Description
<head> Defines information about the document
<title> Defines the title of a document
<base> Defines a default address or a default target for all links on a page
<link> Defines the relationship between a document and an external resource
<meta> Defines metadata about an HTML document
<script> Defines a client-side script
<style> Defines style information for a document

 







HTML Entities


Reserved characters in HTML must be replaced with character entities.

Characters, not present on your keyboard, can also be replaced by entities.


HTML Entities

Some characters are reserved in HTML.

If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags.

Character entities are used to display reserved characters in HTML.

A character entity looks like this:

&entity_name;

OR

& #entity_number;

To display a less than sign we must write: &lt;or &#60;

Note The advantage of using an entity name, instead of a number, is that the name is easier to remember.
The disadvantage is that browsers may not support all entity names, but the support for numbers is good.

Non-breaking Space

A common character entity used in HTML is the non-breaking space (&nbsp;).

Remember that browsers will always truncate spaces in HTML pages. If you write 10 spaces in your text, the browser will remove 9 of them. To add real spaces to your text, you can use the &nbsp;character entity.


Some Other Useful HTML Character Entities

Result Description Entity Name Entity Number
non-breaking space &nbsp; &#160;
< less than &lt; &#60;
> greater than &gt; &#62;
& ampersand &amp; &#38;
¢ cent &cent; &#162;
£ pound &pound; &#163;
¥ yen &yen; &#165;
euro &euro; &#8364;
© copyright &copy; &#169;
® registered trademark &reg; &#174;

Note

 Entity names are case sensitive.


Combining Diacritical Marks

A diacritical mark is a "glyph" added to a letter.

Some diacritical marks, like grave (  ̀) and acute (  ́) are called accents.

Diacritical marks can appear both above and below a letter, inside a letter, and between two letters.

Diacritical marks can be used in combination with alphanumeric characters, to produce a character that is not present in the character set (encoding) used in the page.

Here are some examples:

Mark Character Construct Result
  ̀ a a&#768;
  ́ a a&#769;
̂ a a&#770;
  ̃ a a&#771;
  ̀ O O&#768;
  ́ O O&#769;
̂ O O&#770;
  ̃ O O&#771;

You will see more HTML symbols in the next chapter of this tutorial.


 







HTML and XHTML


XHTML is HTML written as XML.


What Is XHTML?


Why XHTML?

Many pages on the internet contain "bad" HTML.

this HTML code works fine in most browsers (even if it does not follow the HTML rules):

<html>
<head>
 <title>this is bad HTML</title>

<body>
 <h1>Bad HTML
 <p>this is a paragraph
</body>

Today's market consists of different browser technologies. Some browsers run on computers, and some browsers run on mobile phones or other small devices. Smaller devices often lack the resources or power to interpret "bad" markup.

XML is a markup language where documents must be marked up correctly (be "well-formed").

By combining the strengths of HTML and XML, XHTML was developed.

XHTML is HTML redesigned as XML.


the Most Important Differences from HTML:

Document Structure

XHTML Elements

XHTML Attributes


<!DOCTYPE ....> Is Mandatory

An XHTML document must have an XHTML DOCTYPE declaration.

A complete list of all the XHTML Doctypes is found in the HTML Tags Reference.

The <html>, <head>, <title>, and <body> elements must also be present, and the xmlns attribute in <html> must specify the xml namespace for the document.

this example shows an XHTML document with a minimum of required tags:

<!DOCTYPE html PUBliC "-//W3C//Dtd XHTML 1.0 transitional//EN"
"http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
 <title>title of document</title>
</head>

<body>
  some content
</body>

</html>

XHTML Elements Must Be Properly Nested

In HTML, some elements can be improperly nested within each other, like this:

<b><i>this text is bold and italic</b></i>

In XHTML, all elements must be properly nested within each other, like this:

<b><i>this text is bold and italic</i></b>

XHTML Elements Must Always Be Closed

this is wrong:

<p>this is a paragraph
<p>this is another paragraph

this is correct:

<p>this is a paragraph</p>
<p>this is another paragraph</p>

Empty Elements Must Also Be Closed

this is wrong:

A break: <br>
A horizontal rule: <hr>
An image: <img src="happy.gif" alt="Happy face">

this is correct:

A break: <br />
A horizontal rule: <hr />
An image: <img src="happy.gif" alt="Happy face" />

XHTML Elements Must Be In Lower Case

this is wrong:

<BODY>
<P>this is a paragraph</P>
</BODY>

this is correct:

<body>
<p>this is a paragraph</p>
</body>

XHTML Attribute Names Must Be In Lower Case

this is wrong:

<table WIDth="100%">

this is correct:

<table width="100%">

Attribute Values Must Be Quoted

this is wrong:

<table width=100%>

this is correct:

<table width="100%">

Attribute Minimization Is Forbidden

Wrong:

<input type="checkbox" name="vehicle" value="car" checked />

Correct:

<input type="checkbox" name="vehicle" value="car" checked= "checked" />

Wrong:

<input type="text" name="lastname" disabled />

Correct:

<input type="text" name="lastname" disabled="disabled" />

How to Convert from HTML to XHTML

  1. Add an XHTML <!DOCTYPE> to the first line of every page
  2. Add an xmlns attribute to the html element of every page
  3. Change all element names to lowercase
  4. Close all empty elements
  5. Change all attribute names to lowercase
  6. Quote all attribute values

Validate XHTML With the W3C Validator

Put your web address in the box below: