L02 HTML
L02 HTML
Khai Truong
Markup languages
Provides control over the organization of a document’s content
● Specify content structure (e.g., titles, headers, paragraphs, groups
of texts/elements that belong together)
● Formats content for presentation
Example: LaTeX
https://data-mining.philippe-fournier-viger.com/wp-content/uploads/2017/02/latex.png
Standard Generalized Markup Language (SGML)
SGML is an ISO (Internet Organization for Standardization) standard
accepted in 1986
"A meta-language for generating descriptive markup languages"
(Coombs, Renear, and DeRose 1987) rather than a specific markup
language itself
● It only specify rules for tagging elements
https://www.w3schools.com/html/html_intro.asp
Example
This is a comment.
Example:
<p>first paragraph</p>
Example:
<section> start tag
<p>first paragraph</p> } paragraph element
section element
<p>second paragraph</p> } paragraph element
</section> End tag
List of void elements: area, base, br, col, embed, hr, img, input, link, meta,
source, track, wbr
Basic HTML tags
<html>
● The root element
● All other tags must be declared within <html>...</html>
<head>
● The “invisible” part of an HTML document
● Contains metadata which typically define document title, character
set, styles, scripts, and other information about the document
<body>
● The “visible” part of an HTML document
Basic HTML tags (part 2)
<header>, <main>, <footer>
● <header> and <footer> are analogous to the header and footer of a
printed document
● <main> is the dominant content of the <body>
The method attribute specifies how to send input data when the form is
submitted
● GET: usually used for queries and filters (e.g., Google search)
○ Data is appended to the URL in name-value pairs
● POST: usually used for uploading files or submitting web form
○ data sent in body of HTTP request
Don’t use GET to send sensitive data!
GET is limited by the length of a URL
Form submissions with POST cannot be bookmarked
Non-semantic elements
Organizing elements
<div>: division tag
● Block level element
● Changes to a new line wherever defined
● Used extensively for organizing and
styling elements
● Can be styled to provide spacing and
alignment of child elements
<span>: span tag
● Inline element
● Allows styling of an inline element or text
https://media.gcflearnfree.org/content/5e82363212da9215e057b928_03_30_2020/block_vs_inline_diagram.png
Some notes about writing HTML
Whitespaces in HTML files are ignored
Preformatted text
Browsers can be asked to preserve spaces and line breaks when
rendering text inside the <pre> tag.
Often used to show source code
HTML entities
Characters are used by the HTML language (e.g., “<”)
Those characters must be replaced by their HTML entity equivalence
(which starts with ampersand, followed by entity name or number,
and ends with a semicolon)
E.g., to display <, < or < is used instead
Go to https://validator.w3.org/
Summary
You have learned about 80% of the HTML tags needed for A1
Learn more on your own: http://www.w3schools.com/html
Experiment, search online, and/or read reference manuals
Reproduction and/or sharing of course materials is prohibited. Course materials include lecture slides, course notes,
assignments, data and documents provided by the instructors. Course materials created by the instructors of this course
are their intellectual properties. They may not be shared, posted, rehosted, sold, or otherwise distributed and/or
modified without expressed permission from the authors. All such reproduction or dissemination is an infringement of
copyright and is prohibited. All rights are reserved by the instructors.