LMGSI Unit 2 HTML - Links - Student Version
LMGSI Unit 2 HTML - Links - Student Version
Management Systems
(Multiplatform Application Development)
Author:
José David Balibrea Sánchez
Computer Science Department
Unit 2: HTML
(HyperText
Markup
Language)
Author: José David Balibrea Sánchez
Índex
1. HTML: HyperText Markup 3. HTML Content and text tags
Language 3.1. HTML Content tags
1.1. What is a Markup Language? 3.1.1. Most commonly used
1.2. What is HTML? attributes in tags
1.3. HTML Editors
3.1.2. Attributes for lists
1.4. HTML Tags
1.5. Empty or self-closing tags in HTML 3.2. HTML Text tags
1.6. HTML document 3.2.1. Hyperlinks: values of the
1.7. HTML Comments href Attribute
3.2.2. Hyperlinks: target attribute
2. HTML Semantic tags
2.1. Semantic tags 3.2.3. Hyperlink: download
attribute
2.2. Advantages of using semantic tags
3.3. Special Characters in HTML
LMGSI (DAM) - IES El Pla 3
Índex
4. HTML Form tags 5. HTML Table tags
4.1. form attributes 5.1. Table tags
4.2. Form tags 5.2. Grouping cells in tables using
rowspan and colspan
4.3. Form input attributes
5.3. Table border, align, and bgcolor
4.4. Form input: type attribute values attributes
4.5. <textarea> tag
4.6. <select> tag
6. HTML tags for embedding content
6.1. Tags for embedding content
4.7. <button> tag
6.2. img tag
4.8. <label> tag
4.9. <fieldset> and <legend> tags 6.3. Embed YouTube videos &
playlists
4.10. Pattern attribute and regular
6.4. Embed a Google map
expression
LMGSI (DAM) - IES El Pla 4
Índex
7. Page jumping or jump links
7.1. How to create an jump link
7.2. How to create an anchor link that can be accessed from another page
8. Meta tags in HTML
9. W3C Markup Validation Service
10. Ordered elements in HTML5
10.1. HTML Block Elements
10.2. HTML Inline Elements
11. HTML. Technical Vocabulary
12. HTML Tags Summary
• Learn how to use Codepen (enables you to build web development projects online and to see
a lot of examples).
• Practice other Emmet abbreviations for high-speed coding.
LMGSI (DAM) - IES El Pla 27
1. HTML: HyperText Markup Language
Exercise 2. Basic structure of an HTML document. Fill in the Blanks:
<!DOCTYPE html>
<html ="en">
<head>
<meta ="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
< href="style.css" rel="stylesheet">
< >Document</ >
</head>
< >
Hello World!
</ >
</ >
LMGSI (DAM) - IES El Pla 28
1. HTML: HyperText Markup Language
Exercise 3. Drag the words and drop them into the answer area:
→ It specifies the HTML version being used, which is HTML5 in this case.
→ It defines the document type as HTML and provides a container for all other HTML
elements, such as <head> and <body>.
→ It is not visible to users but plays a crucial role in providing important information to
browsers and search engines.
→ The title of the webpage, which is displayed in the browser’s title bar or tab.
<p>Pasa el puntero por encima de la siguiente etiqueta abbr: <abbr title="Hypertext Markup Language">HTML</abbr></p>
In this example, the form has an action attribute specifying where the form data
should be submitted. The method attribute determines the HTTP method to be
used (POST in this case). Each input element has a type, id, and name attribute for
identification and data collection. The submit input triggers form submission.
LMGSI (DAM) - IES El Pla 66
4. HTML Form tags
4.1. Form attributes
Both the action and method attributes are used together to determine how the
form data will be sent and processed. It is important to consider security and the
purpose of the form when choosing the appropriate method. Example:
• action: It specifies the URL or route to which the form data will be sent when it is
submitted. It can be a relative or absolute URL that indicates where the form data
will be sent for processing.
• method: It can be either «GET» or «POST» and determines the HTTP method that
will be used to send the form data to the server. The main difference lies in how
the data is transmitted.
LMGSI (DAM) - IES El Pla 67
4. HTML Form tags
4.1. Form attributes
• method: It can be either «GET» or «POST» and determines the HTTP method that
will be used to send the form data to the server. The main difference lies in how
the data is transmitted.
• GET: The form data is appended to the URL as query parameters. It is the
default method if the method attribute is not specified. It is useful when you
want the form data to be visible in the URL, for example, when performing
searches.
• POST: The form data is sent in the body of the HTTP request in a more secure
manner and is not shown in the URL. It is suitable for sending sensitive data
such as passwords or personal information.
(example and exercises click on this link)
LMGSI (DAM) - IES El Pla 68
4. HTML Form tags
4.2. Form tags
HTML form tags are used to create interactive forms on web pages. Here are some
commonly used form tags (example and exercises click on this link):
Element Description
<form> It is used to create a form for user input.
<fieldset> It is used to group elements in a form. It draws a box around the
elements.
<legend> It is used to define a caption for the <fieldset> element.
<input> It is used to specify an input field where the user can enter information.
<button> It specifies a button.
Type Description
text Default value. A single-line text field.
time Control for entering a time value.
Field for entering a URL. Looks like a text input, but has validation
url
parameters.
week Control for entering a date.
You can also add the multiple attribute to allow multiple selections:
In this example, we have a <select> element with three <option> elements inside it.
Each <option> represents a selectable item in the dropdown list. The value attribute
specifies the value associated with each option, which can be used for form
submission or JavaScript manipulation. Furthermore, the second <option> element
has the selected attribute, which means «Option 2» will be pre-selected when the
page loads. Users can still change the selection if desired.
(example and exercises click on this link)
LMGSI (DAM) - IES El Pla 80
4. HTML Form tags
4.7. <button> tag
The <button> tag in HTML is used to create a clickable button on a webpage. It can be
used to trigger a specific action or behavior when clicked. Here’s an example:
<button>Click me</button>
In this example, a simple button with the text «Click me» is created.
You can also use the type attribute to define the type of button. Some common values
for the type attribute are:
• button (default): A standard button.
• submit: A button that submits a form.
• reset: A button that resets form inputs to their initial values.
Here’s an example with the type attribute:
<button type="submit">Submit</button>
This button, when clicked, will submit the form it belongs to.
(example and exercises click on this link)
LMGSI (DAM) - IES El Pla 81
4. HTML Form tags
4.8. <label> tag
The <label> tag in HTML is used to define a label for an HTML form element. It helps in
associating a text description with a form input, making it more accessible and user-
friendly. Here’s an example:
In this example, the <label> tag is used to create a label for the username input field.
The for attribute of the <label> tag specifies which input element it is associated with.
In this case, the for attribute value matches the id attribute of the input field.
When a user clicks on the label, the corresponding input field is focused or activated.
This improves usability and accessibility, as users can click on the label text instead of
directly clicking on the input field.
Using the <label> tag is important for creating accessible and well-structured forms in
HTML. It improves usability, especially for users with assistive technologies.
(example and exercises click on this link)
LMGSI (DAM) - IES El Pla 82
4. HTML Form tags
4.9. <fieldset> and <legend> tags
The <fieldset> and <legend> tags in HTML are used to group related form elements
together and provide a descriptive caption or title for the group.
The <fieldset> tag acts as a container that holds a group of form elements. It helps in
organizing and structuring the form by visually grouping related fields.
Here’s an example:
In this example, the <fieldset> tag wraps the group of form elements related to contact
information. The <legend> tag is used as a caption or title for the fieldset, providing a
description of the group.
LMGSI (DAM) - IES El Pla 83
4. HTML Form tags
4.9. <fieldset> and <legend> tags
The rendered output will display the legend text as the title of the fieldset, visually
separating the grouped fields from other form elements.
Using <fieldset> and <legend> tags helps improve the accessibility and usability of
forms by providing a clear structure and visual grouping of related fields. It also
enhances (mejora) the overall styling (estilo general) and organization of the form.
(example and exercises click on this link)
LMGSI (DAM) - IES El Pla 84
4. HTML Form tags
4.10. Pattern attribute and regular expressions
The pattern attribute allows you to apply regular expressions to validate and control
the input values of certain elements. Regular expressions are powerful patterns used
for matching and manipulating strings.
A regular expression, often abbreviated as regex or regexp, is a sequence of characters
that forms a search pattern. It is a powerful tool used for pattern matching and
manipulating strings. Here are some commonly used regular expressions in HTML
attributes:
Expression Description
[abc] Any of the characters between the brackets
[^abc] Any character NOT between the brackets
[a-g] Any of the characters between the brackets
(a|b) Any of the alternatives separated with |
LMGSI (DAM) - IES El Pla 85
4. HTML Form tags
4.10. Pattern attribute and regular expressions
Metacharacter Description
. A single character, except newline or line terminator
\w\ d \s Word, digit, whitespace character
\W \D \S Non-word character, non-digit character, non-whitespace character
\t \n \r Tab character, new line character, carriage return character
Quantifier Description
a* a+ a? Zero or more, one or more, zero or one occurrences
a{5} a{2,} Only 5, 2 or more
a{1,3} Between 1 and 3
^a Any string with a at the beginning of it
a$ (example
Any string withand
a atexercises
the end ofclick
it on this link)
LMGSI (DAM) - IES El Pla 86
4. HTML Form tags
4.10. Pattern attribute and regular expressions
Examples:
Here are some commonly used regular expressions in HTML attributes:
Email Validation: This pattern validates that the input value is a valid email address.
<input type="email" pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"
required>
URL Validation: This pattern ensures that the input value starts with either «http://» or
«https://».
<input type="url" pattern="https?://.+">
Numeric Input: This pattern allows only numeric input in the field.
<input type="number" pattern="[0-9]+">
Custom Pattern: This pattern specifies a custom format where the input should start
with three letters followed by three digits.
<input type="text" pattern="[A-Za-z]{3}\d{3}">
LMGSI (DAM) - IES El Pla 87
4. HTML Form tags
4.10. Pattern attribute and regular expressions
Examples:
Here are some commonly used regular expressions in HTML attributes:
ZIP Code Validation: This pattern ensures that the input value is a valid 5-digit ZIP
code.
<input type="text" pattern="[0-9]{5}">
Date Validation (YYYY-MM-DD format): This pattern validates the input value as a
date in the format of YYYY-MM-DD.
<input type="text" pattern="\d{4}-\d{2}-\d{2}">
Username Validation (alphanumeric characters only): This pattern allows only
alphanumeric characters for the username input.
<input type="text" pattern="[A-Za-z0-9]+">
In this example, Cell 2 spans across two columns. Using rowspan and colspan allows
for flexible table layouts and the merging of cells to create complex table structures.
(examples w3c, click on this link)
LMGSI (DAM) - IES El Pla 92
5. HTML Table tags
5.3. Table border, align, and bgcolor attributes
1. Border attribute: Specifies the width of the border around the table cells.
The value is given in pixels. Example: <table border="1">
2. Align attribute: Determines the horizontal alignment of the table within its
container. Possible values are «left,» «center,» or «right.» Example: <table
align="center">
3. Bgcolor attribute: Sets the background color of the table. You can use color
names or hexadecimal color codes. Example: <table bgcolor="#f1f1f1">
These attributes can be applied to the <table> tag to control the appearance and
layout of HTML tables. However, it is recommended to use CSS styles instead for
better control and separation of concerns.
(examples w3c, click on this link)
LMGSI (DAM) - IES El Pla 93
5. HTML Table tags
Exercise 4. Drag the words and drop them into the answer area:
→ Defines a table.
→ Defines a table caption.
→ Defines a row in a table.
→ Defines a cell in a table.
→ Defines a header cell in a table.
→ Specifies a group of one or more columns in a table for formatting.
→ Specifies column properties for each column within a <colgroup>.
(example and exercises click on this link)
LMGSI (DAM) - IES El Pla 94
6. HTML tags for embedding content
HTML provides several tags for embedding content within a web page.
6.1. Tags for embedding content
Here are some commonly used tags for embedding different types of content:
Tag Description
<img> Used to embed images.
<iframe> Used to embed content from another web page within the current page.
<embed> Used to embed multimedia content, such as Flash or interactive media.
<object> Used to embed multimedia content, such as Flash, audio, or video.
<video> Used to embed videos. View more
<audio> Used to embed audio files. View more
When a user clicks on this link, the browser will scroll to the section with the
corresponding name attribute, allowing them to quickly navigate to that specific
part of the page.
These tags are placed between the <head> and </head> tags. Some of the most
common meta tags for metadata in HTML are:
1. <title>: Defines the title of the document, which is displayed in the browser’s
title bar and search results.
2. <meta charset="UTF-8">: Specifies the character encoding used in the
document. UTF-8 is the most commonly used encoding to support multilingual
characters.
LMGSI (DAM) - IES El Pla 105
8. Metadata or meta tags in HTML
These tags are placed between the <head> and </head> tags. Some of the most
common meta tags for metadata in HTML are (cont.):
3. <meta name="description" content="Description of website">: Provides a
brief description of the website’s content. It is used by search engines to display
information about the site in search results.
4. <meta name="keywords" content=“keyword 1, keyword 2">: Specifies
keywords related to the website’s content. Although not as relevant for modern
search engines, it can still be used to understand the website’s theme.
5. <meta name="viewport" content="width=device-width, initial-scale=1.0">:
Defines how the content should adjust and scale on mobile devices. It is
important for achieving a responsive design. See viewport meta tag
configuration.
LMGSI (DAM) - IES El Pla 106
8. Metadata or meta tags in HTML
These tags are placed between the <head> and </head> tags. Some of the most
common meta tags for metadata in HTML are (cont.):
6. <meta name="author" content=“Name of author of html document">:
Specifies the name of the document’s author.
7. <meta name="copyright" content=“year of copyright, name of the author’s
rights">: Indicates the copyright of the document.
8. <meta name="robots" content="index,follow">: Instructs search engines
whether they should index and follow links within the document.
9. <meta http-equiv="refresh" content="30">: Refresh document every 30
seconds
(example and summary table, click on this link)
LMGSI (DAM) - IES El Pla 107
8. Metadata or meta tags in HTML
These tags are placed between the <head> and </head> tags and his syntax is:
<meta attribute=“value”>. You can see a table with the most used attributes and
values:
Attributes Value Description
charset character_set Specifies the character encoding for the HTML
document
content text Specifies the value associated with the http-equiv
or name attribute
http-equiv content-security-policy Provides an HTTP header for the
content-type information/value of the content attribute
default-style
refresh
LMGSI (DAM) - IES El Pla 108
8. Metadata or meta tags in HTML
These tags are placed between the <head> and </head> tags and his syntax is:
<meta attribute=“value”>. You can see a table with the most used attributes and
values (cont.):
Validating HTML is an important step to ensure that your HTML code follows
the correct syntax and adheres to the standards set by the HTML
specification. By validating your HTML, you can identify and fix any errors or
inconsistencies in your code, which helps improve the compatibility,
accessibility, and overall quality of your web pages.
There are several online tools and validators available that can help you
validate your HTML code. One popular option is the W3C Markup Validation
Service, which is provided by the World Wide Web Consortium (W3C). You
can access the service at validator.w3.org and submit your HTML code for
validation.
LMGSI (DAM) - IES El Pla 110
10. Ordered elements in HTML5
HTML elements can be categorized as either block-level elements or inline
elements based on their default display behavior.
10.1. HTML block elements
Block-level elements start on a new line and take up the full width available.
Block tags:
<address><article><aside><blockquote>
<canvas><dd><div><dl><dt><fieldset>
<figcaption><figure><footer><form>
<h1>-<h6><header><hr><li><main>
<nav><noscript><ol><p><pre>
<section><table><tfoot><ul><video>
Inline tags:
<a><abbr><acronym><b><bdo><big><br><button><cite><code><dfn><em><i>
<img><input><kbd><label><map><object><output><q><samp><script><select>
<small><span><strong><sub><sup><textarea><time><tt><var>