Académique Documents
Professionnel Documents
Culture Documents
What is HTML?
Ejemplo HTML
<!DOCTYPE html>
<html>
<head>
<title>Ttulo de la Pgina El ttulo es un metadato</title>
</head>
<body>
</body>
</html>
Explicacin:
The text between <head> and </head> provides information about the document
The text between <title> and </title> provides a title for the document, es un metadato
The text between <body> and </body> describes the visible page content
<tagname>content</tagname>
Navegador Web
El propsito de un navegador web (Chrome, IE, Firefox, Safari) es leer documentos HTML y
mostrarlos.
El navegador web no muestra los HTML tags (etiqueta), pero los usa para determinar cmo
mostrar el documento.
Estructura HTML
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<!DOCTYPE HTML>
<!doctype html>
<!Doctype Html>
Declaraciones Comunes:
HTML5
<!DOCTYPE html>
HTML 4.01
XHTML 1.0
Versiones HTML:
Version Year
HTML 1991
HTML 2.0 1995
HTML 3.2 1997
HTML 4.01 1999
XHTML 2000
HTML5 2014
Escribir en HTML usando un editor de texto
Guardar con un nombre y una extensin .html (es posible guardar con la extensin .htm o .html)
Se presiona click derecho en el documento guardado como HTML y se selecciona abrir con, a
continuacin se selecciona un navegador web.
Documentos HTML
La cabecera HTML
La cabecera contiene los datos tipo meta data, los me ta data no son visibles
Un meta dato significa datos acerca de datos. Los meta datos html son datos acerca del
documento html.
HTML Ttulos
HTML Paragraphs
The source file (src), alternative text (alt), and size (width and height) are provided as attributes:
Ejemplo:
<!DOCTYPE html>
<html>
<body>
<h2>Spectacular Mountain</h2>
<img src="pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">
</body>
</html>
Es mejor utilizar style para las imgenes, ya que previene que la imagen cambie del tamao
original.
Se puede acceder a cualquier imagen de la web en cualquier sevidor, solo se requiere la url:
<img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com">
<!DOCTYPE html>
<html>
<body>
<a href="http://www.w3schools.com">
<img src="smiley.gif" alt="HTML tutorial"
style="width:42px;height:42px">
</a>
</body>
</html>
Se aade border para evitar problemas en algunos navegadores
Imagen Flotante
<!DOCTYPE html>
<html>
<body>
<p>Please use the CSS float property. The align attribute is deprecated in HTML 4, and not
supported in HTML5.</p>
</body>
</html>
Mapas de Imagen
Se usa <map>, un map es una imagen con reas clickeables.
La etiqueta <map> contiene una serie de etiquetas <area>, que define las reas se puede hacer clic
en la imagen.
<!DOCTYPE html>
<html>
<body>
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
</body>
</html>
Resumen
<br> es un elemento vaco sin la etiqueta de finalizacin. <br> significa salto de lnea.
Los elementos vacos pueden ser cerrados en el inicio, as: <br />
HTML5 no require que elementos vacos sean cerrados, pero para estricta validacin o para XML
papers, se deben cerrar estos elementos.
Atributos HTML
Atributo lang
<!DOCTYPE html>
<html lang="en-US">
</html>
Las primeras 2 letras indican el idioma, si hay un dialecto, se usan dos letras ms.
Atributo Ttulo
It provides tutorials and references covering many aspects of web programming, including HTML,
CSS, JavaScript, XML, SQL, PHP, ASP, etc.
</p>
Comillas
Se recomienda siempre usar comillas cuando se utiliza atributo ttulo, ya que omitirlas puede
producir errores; cuando se pone un ttulo que hay varias palabras y no se usa comillas, solo se
muestra la primera palabra; es necesario usar comillas.
Las comillas dobles son las ms comunes en HTML, pero se pueden utilizar las simples.
En algunas situaciones, cuando el atributo por s mismo contiene comillas dobles, es necesario
poner comillas simples:
O viceversa:
Aqu va el prrafo 1
</p>
The HTML width and height attributes provide size information for images
Attribute Description
alt Specifies an alternative text for an image
disabled Specifies that an input element should be
disabled
href Specifies the URL (web address) for a link
id Specifies a unique id for an element
src Specifies the URL (web address) for an image
style Specifies an inline CSS style for an element
title Specifies extra information about an element
(displayed as a tool tip)
Elemento <meta>
Puede ser usado para definir un carcter u otra informacin acerca del documento HTML.
Tag Description
<html> Defines an HTML document
<body> Defines the document's body
<head> Defines the document's head element
<h1> to <h6> Defines HTML headings
<hr> Defines a horizontal line
El texto que est dentro de <pre> y </pre> se muestra con una fuente fija (generalmente courier)
y preserva tanto espacios como lneas.
Resumen
Tag Description
<p> Defines a paragraph
<br> Inserts a single line break
<pre> Defines pre-formatted text
Estilos
style="propiedad:valor;"
Color de Fondo
<body style="background-color:lightgrey;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
Color de Fondo de Texto (Resaltado)
<h2 style="background-color:red">
</h2>
<h2 style="background-color:rgb(0,0,255)">
</h2>
Sombras
<h2 style="background-color:rgb(0,0,0);color:white">
</h2>
<h2 style="background-color:rgb(128,128,128);color:white">
</h2>
<h2 style="background-color:rgb(255,255,255);">
</h2>
Colores Hexadecimal
<h2 style="background-color:#00FFFF">
</h2>
Sombras Hexadecimal
<h2 style="background-color:#000000;color:white">
</h2>
Color de texto
Tipo de letra
Alineacin
<body style="text-align:center">
<p>This is a paragraph.</p>
Internal Style
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:lightgrey;font-family:courier}
h1 {color: blue;}
p {color: green;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
</body>
</html>
Estilo Externo: Se puede usar un estilo externo previamente guardado en un archivo .ccs
Para usar el estilo externo, se aade una lnea en <head>
<!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>
Se debe crear otro archive con la extensin css, este archivo no debe contener ninguna etiqueta
html, en este caso se crea el archivo styles.css en blog de notas:
body {
background-color: lightgrey;
}
h1 {
color: blue;
}
p{
color:green;
}
Fuentes CSS
Se puede definir tanto color, family (tipo de letra), size (tamao) en el encabezado <head>
<!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>
<!DOCTYPE html>
<html>
<head>
<style>
p{
border: 1px solid grey;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
</body>
</html>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p class="error">I am different.</p>
<p>This is a paragraph.</p>
<p class="error">I am different too.</p>
</body>
</html>
Ejemplo 2
<!DOCTYPE html>
<html>
<head>
<style>
p.intro {
background-color:black;
color:white;
border:1px solid grey;
padding:10px;
margin:30px;
font-size:150%;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p class="intro">This is a paragraph.</p>
<p class="intro">This is a paragraph.</p>
<p class="intro">This is a paragraph.</p>
</body>
Resumen
Resumen
Sin embargo existe una diferencia: <b> e <i> define negrita y texto italico, pero <strong> y <em>
significa que el texto es importante.
Resumen
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 Links
Ejemplo:
Links locales
Un link local (al mismo sitio web) se especifica con una url relativa (sin http://www...)
Colores en el link
Cuando se posiciona sobre el link, dos cosas suceden:
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
</style>
</head>
<body>
</body>
</html>
Tarjet
<!DOCTYPE html>
<html>
<body>
<p>If you set the target attribute to "_blank", the link will open in a new browser window or
tab.</p>
</body>
</html>
Ejemplo:
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0">
</a>
<p>We have added "border:0" to prevent IE9 (and earlier) from displaying a border around the
image.</p>
</body>
</html>
border:0 se utiliza para prevenir que se despliegue un borde en la figura, en IE9 y anteriores.
Bookmark Links
til cuando es un documento largo, se puede saltar directamente a otro lugar:
<!DOCTYPE html>
<html>
<body>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 5</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 6</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 7</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 8</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 9</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 10</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 11</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 12</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 13</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 14</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 15</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 16</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 17</h2>
<p>This chapter explains ba bla bla</p>
</body>
</html>
Elementos de Citacin
<p>WWF's goal is to: <q>Build a future where people live in harmony with nature.</q></p>
<abbr>: Abreviacin o acrnimo, las abreviaciones den informacin til a los navegadores,
sistemas de traduccin y bsqueda, si se pone el cursor sobre la palabra, se leer la abreviacin.
Resumen
Tag Description
<abbr> Defines an abbreviation or acronym
<address> Defines contact information for the
author/owner of a document
<bdo> Defines the text direction
<blockquote> Defines a section that is quoted from another
source
<cite> Defines the title of a work
<q> Defines a short inline quotation
<code>: Elemento que define una parte de un cdigo de programacin, puede ser utilizada con
<pre>
<pre>
<code>
var x = 5;
var y = 6;
document.getElementById("demo").innerHTML = x + y;
</code>
</pre>
Resumen
HTML Computer Code Elements
Tag Description
<code> Defines programming code
<kbd> Defines keyboard input
<samp> Defines computer output
<var> Defines a variable
<pre> Defines preformatted text
Comentarios
Tablas
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
Tabla Ttulos
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
Combinar filas
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
</body>
</html>
Combinar Columnas
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
</body>
</html>
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
</body>
</html>
Estilo especial para Tabla (color de Fondo, color de letra, fuente, tamao de fuente)
En general todas las tablas van a tener los primeros atributos, pero se definen otros atributos para
la tabla 01
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
table#t01 {
width: 100%;
background-color: #f1f1c1;
color: blue;
font-family: courier;
font-size: 160%;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
<br>
<table id="t01">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
Color de Letra en la tabla, distinto color de fondo dependiendo de filas pares o impares (ver)
<!DOCTYPE html>
<html>
<head>
<style>
table {
width:100%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
table#t01 tr:nth-child(even) {
background-color: #eee;
}
table#t01 tr:nth-child(odd) {
background-color:#fff;
}
table#t01 th {
background-color: black;
color: white;
}
</style>
</head>
<body>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
<br>
<table id="t01">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
Resumen
Use the HTML <table> element to define a table
Use the HTML <tr> element to define a table row
Use the HTML <td> element to define a table data
Use the HTML <th> element to define a table heading
Use the HTML <caption> element to define a table caption
Use the CSS border property to define a border
Use the CSS border-collapse property to collapse cell borders
Use the CSS padding property to add padding to cells
Use the CSS text-align property to align cell text
Use the CSS border-spacing property to set the spacing between cells
Use the colspan attribute to make a cell span many columns
Use the rowspan attribute to make a cell span many rows
Use the id attribute to uniquely define one table
Listas
<!DOCTYPE html>
<html>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
Style Description
list-style-type:disc The list items will be marked with bullets
(default)
list-style-type:circle The list items will be marked with circles
list-style-type:square The list items will be marked with squares
list-style-type:none The list items will not be marked
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Listas Ordenadas <ol>
Por defecto se crean los elementos numerados.
Para las listas se utiliza <li> </li>
<!DOCTYPE html>
<html>
<body>
<h2>Ordered List</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Listas Descriptivas
<!DOCTYPE html>
<html>
<body>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<ol>
<li>ron</li>
<li>biela</li>
</ol>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
</body>
</html>
Lista Horizontal
Despliga los elementos horizontalmente.
<!DOCTYPE html>
<html>
<head>
<style>
ul#menu li {
display:inline;
}
</style>
</head>
<body>
<h2>Horizontal List</h2>
<ul id="menu">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>PHP</li>
</ul>
</body>
</html>
Lista horizontal que cambia el color cuando pongo sobre un elemento y me dirige a otra pgina
(ver)
<!DOCTYPE html>
<html>
<head>
<style>
ul#menu {
padding: 0;
}
ul#menu li {
display: inline;
}
ul#menu li a {
background-color: black;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 4px 4px 0 0;
}
ul#menu li a:hover {
background-color: orange;
}
</style>
</head>
<body>
<h2>Horizontal List</h2>
<ul id="menu">
<li><a href="/html/default.asp">HTML</a></li>
<li><a href="/css/default.asp">CSS</a></li>
<li><a href="/js/default.asp">JavaScript</a></li>
<li><a href="/php/default.asp">PHP</a></li>
</ul>
</body>
</html>
Resumen
Use the HTML <ul> element to define an unordered list
Use the HTML style attribute to define the bullet style
Use the HTML <ol> element to define an ordered list
Use the HTML type attribute to define the numbering type
Use the HTML <li> element to define a list item
Use the HTML <dl> element to define a description list
Use the HTML <dt> element to define the description term
Use the HTML <dd> element to define the description data
Lists can be nested inside lists
List items can contain other HTML elements
Use the CSS property display:inline to display a list horizontally
Un elemento en bloque siempre empieza en una nueva lnea y ocupa todo el ancho disponible (se
extiende hacia la izquierda y la derecha en la medida de lo que pueda)
<span>
<a>
<img>
Elemento <div>
<!DOCTYPE html>
<html>
<body>
<h2>London</h2>
<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>
</body>
</html>
Elemento <span>
El elemento <span> es un elemento en lnea que se utiliza a menudo como un contenedor para un
pequeo texto.
El elemento <span> no tiene ningn atributo necesario, pero el estilo y la clase son comunes.
Cuando se utiliza junto con CSS, el elemento <span> se puede utilizar para piezas de estilo del
texto:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Tag Description
<div> Defines a section in a document (block-level)
<span> Defines a section in a document (inline)
El atributo de clase HTML hace que sea posible definir estilos iguales para que elementos <div>
sean "iguales":
<!DOCTYPE html>
<html>
<head>
<style>
div.cities {
background-color:black;
color:white;
margin:20px;
padding:20px;
}
</style>
</head>
<body>
<div class="cities">
<h2>London</h2>
<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 class="cities">
<h2>Paris</h2>
<p>Paris is the capital and most populous city of France.</p>
<p>Situated on the Seine River, it is at the heart of the le-de-France region, also known as the
rgion parisienne.</p>
<p>Within its metropolitan area is one of the largest population centers in Europe, with over 12
million inhabitants.</p>
</div>
<div class="cities">
<h2>Tokyo</h2>
<p>Tokyo is the capital of Japan, the center of the Greater Tokyo Area, and the most populous
metropolitan area in the world.</p>
<p>It is the seat of the Japanese government and the Imperial Palace, and the home of the
Japanese Imperial Family.</p>
<p>The Tokyo prefecture is part of the world's most populous metropolitan area with 38 million
people and the world's largest urban economy.</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.cities {
background-color:black;
color:white;
margin:20px;
padding:20px;
}
</style>
</head>
<body>
<div class="cities">
<h2>London</h2>
<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>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
span.note {font-size:120%;color:red;}
</style>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.special {
color:red;
}
</style>
</head>
<body>
</body>
</html>
Formularios
Type Description
text Defines normal text input
radio Defines radio button input (for selecting one of
many choices)
submit Defines a submit button (for submitting the
form)
Entrada text
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
<form action="action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
Atributo Accin
<form action="action_page.php">
Atributo Mtodo
Especifica el mtodo HTTP a utilizar (GET oPOST).
Get: Si el envo del formulario es pasiva (como un motor de bsqueda consulta), y sin informacin
sensible.
Cuando se utiliza GET, los datos del formulario sern visibles en la direccin de la pgina:
action_page.php?firstname=Mickey&lastname=Mouse
Get se utiliza para tamaos pequeos de datos.
Post ofrece una mayor seguridad ya que los datos presentados no estn visibles en la direccin de
la pgina.
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
El atributo nombre: Para ser presentado correctamente, cada campo de entrada debe tener un
atributo de nombre.
<form action="action_page.php">
First name:<br>
<input type="text" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
El first name no tiene atributo nombre, as que este ser el resultado en el navegador:
<form action="action_page.php">
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
Elementos de Formulario
Elemento Input
Es el elemento ms importante de un formulario.
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
Opcion predefinida:
<p>You can preselect an option with the selected attribute.</p>
<form action="action_page.php">
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat" selected>Fiat</option>
<option value="audi">Audi</option>
</select>
<br><br>
<input type="submit">
</form>
<form action="action_page.php">
<textarea name="message" rows="10" cols="30">The cat was playing in the garden.</textarea>
<br>
<input type="submit">
</form>
Elemento Botn (Ver)
<body>
</body>
<form action="action_page.php">
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<input type="submit">
</form>
<p><b>Note:</b> The datalist tag is not supported in Safari or IE9 (and earlier).</p>
Elemento Keygen
El propsito del elemento <keygen> es proporcionar una forma segura de autenticar a los
usuarios.
El elemento <keygen> especifica un campo generador de par de claves en un formulario.
Cuando se enva el formulario, dos claves se generan, una privada y una pblica.
La clave privada se almacena localmente, y la clave pblica se enva al servidor.
La clave pblica se podra utilizar para generar un certificado de cliente para autenticar al usuario
en el futuro.
<body>
<form action="action_page.php">
Username: <input type="text" name="user">
<br><br>
Encryption: <keygen name="security">
<br><br>
<input type="submit">
</form>
</body>
Elementos de Salida
<form action="action_page.php"
oninput="x.value=parseInt(a.value)+parseInt(b.value)">
0
<input type="range" id="a" name="a" value="50">
100 +
<input type="number" id="b" name="b" value="50">
=
<output name="x" for="a b"></output>
<br><br>
<input type="submit">
</form>
Resumen:
Tag Description
<form> Defines an HTML form for user input
<input> Defines an input control
<textarea> Defines a multiline input control (text area)
<label> Defines a label for an <input> element
<fieldset> Groups related elements in a form
<legend> Defines a caption for a <fieldset> element
<select> Defines a drop-down list
<optgroup> Defines a group of related options in a drop-
down list
<option> Defines an option in a drop-down list
<button> Defines a clickable button
<datalist> Specifies a list of pre-defined options for input
controls
<keygen> Defines a key-pair generator field (for forms)
<output> Defines the result of a calculation
Referencia:
http://www.w3schools.com/tags/