1-HTML 0y9skgo
1-HTML 0y9skgo
www.dominusoft.co
Table of Content
❑ Introduction to WEB
❑ HTTP
❑ Static Web & Dynamic Web
❑ Introduction to HTML
❑ HTML Elements:
o Text o Div and Span
o Lists o Forms
o Links o Audio and Video
o Images o Favicon
o Tables
Introduction WEB -
World Wide Web (www)
❑ The World Wide Web (www, W3) is an information system of
interlinked hypertext documents and other digital resources that
are accessed via the Internet.
❑ Set of:
o Communication protocols;
o Data formats.
❑ The web page never changes its content, until the author changes it.
❑ The content of the page:
o Does not depend on the interaction with the user;
o Does not depend on the information sent by the client to the
server;
o Does not depend on the time it is requested.
❑ Page implemented in HTML / CSS.
Static web: pros and cons
❑ Every web page is associated with an HTML file.
Props: Cons:
❑ Maximum efficiency (low load ❑ Data is static;
on CPU);
❑ No adaptation to clients and
❑ Possibility to perform page their capabilities.
caching:
o in RAM (by the server);
o on disk (by client).
❑ Pages can be indexed by search
engines.
Static web with dynamic pages
❑ The client evaluates the dynamic content of the page (script, or Java
applet, or ActiveX control).
In Static Web with Dynamic
pages
Props: Cons:
❑ Efficient (low CPU load on ❑ Inefficient (medium-high CPU
servers); load on clients);
<hr width=“90%”>
Name of Value of
attribute attribute
The browsers
❑ Visualizing HTML documents (and navigate them) requires an
appropriate program, an HTML browser.
❑ A browser is an interpreter:
o Reads the source code (HTML + extensions);
o Tries to understand it (hoping there are no errors …);
o Does its best to visualize what is described by the source code.
❑ Attention! Not every browser visualizes a given document in the
same way.
❑ Graphical browsers: Firefox, Chrome, Opera, Internet Explorer,
Safari.
The browsers: Notes
❑ http://validator.w3.org
o Allows verifying if a page fully satisfies the official syntax.
o Can provide detailed explanations on the errors and on
how to correct them.
❑ http://tidy.sourceforge.net:
o "Cleans" the HTML code and transforms it to more
recent versions recent versions.
❑ Problems with dynamically generated HTML (cannot validate an
ASP or PHP source page).
How to create HTML
documents - 1
❑ Right click on desktop.
How to create HTML
documents - 1
1. Create a txt file – give a name to the file
and end it with .html.
2. Click Yes.
<head>
<meta charset="UTF-8"> meta
<meta http-equiv="X-UA-Compatible" content="IE=edge">
head <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title of the tab</title> title
</head>
html
<body>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation Paired
body ullamco laboris nisi ut aliquip ex ea commodoconsequat. tag
Duis aute irure dolor in reprehenderit in voluptate velit
</p>
</body>
</html>
HTML – Structure tags
❑ DOCTYPE html – Ensures that the browser makes a best-effort attempt
at following the relevant specifications, tell browsers which version of
HTML you are using.
❑ html - Represents the root (top-level element) of an HTML document,
so it is also referred to as the root element. All other elements must be
descendants of this element.
❑ head – Contains information about the page.
❑ title - The title (and in general the data inside the head) is very
important since it is the element most used by automatic indexing
services. Are shown in the top of the browser, above where you usually
type in the URL of the page you want to visit, or on the tab for that
page.
❑ body - Everything inside this element is shown inside the main browser
window.
Comments
❑ If you want to add a comment to your code that will not be visible in the
user's browser.
❑ Can be inserted at every point in the text.
❑ Can span multiple lines.
❑ Enclosed inside <!-- and -->.
❑ You can use comment for:
o When you come back to the code later (or if someone else needs to
look at the code), comments will make it much easier to understand;
o To indicate where sections of the page start or end;
o Can also be used around blocks of code to stop that code from being
displayed in the browser.
Meta-data
❑ Meta data are set inside <head> ….</head>.
❑ It is not visible to users.
❑ It uses attributes to carry the information.
❑ Data useful for:
o Indexing the HTML page;
o Providing information to the web server and / or to the browser.
❑ Syntax:
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Introduction to HTML, Static Web
vs Dynamic Web, HTML Elements" />
<meta name="keywords" content="HTML, art, opinion" />
<meta http-equiv="author" content="Jane Doe" />
HTML Text: Headings
❑ There are six levels of headings or titles:
• <h1> is used for main headings,
<h2> is used for subheadings. If Headings in HTML file
there are further sections under the
subheadings then the <h3> element <h1>This is a Main Heading</h1>
is used, and so on...; <h2>This is a Level 2 Heading</h2>
<h3>This is a Level 3 Heading</h3>
• Browsers display the contents of <h4>This is a Level 4 Heading</h4>
headings at different sizes; <h5>This is a Level 5 Heading</h5>
• Should be used according to the <h6>This is a Level 6 Heading</h6>
logical meaning (semantics), not to
achieve a specific formatting;
• In particular, it is not correct to
us <hN> if not preceded by
<hN-1>.
HTML Text: Paragraphs
❑ To create a paragraph, surround the words that make up the
paragraph with an opening and closing tag <p>…</p>.
❑ By default, a browser will show each paragraph on a new line with
some space between it and any subsequent paragraphs.
❑ Example:
<p>A paragraph consists of one or more sentences
that form a self-contained unit of discourse. The
start of a paragraph is indicated by a new
line.</p>
<p>Text is easier to understand when it is split up
into units of text. For example, a book may have
chapters. Chapters can have subheadings. Under
each heading there will be one or more
paragraphs.</p>
HTML Text: White Space
❑ In order to make code easier to read, web page authors often add
extra spaces or start some elements on new lines;
❑ When the browser comes across two or more spaces next to each
other, it only displays one space;
❑ Similarly, if it comes across a line break, it treats that as a single
space too;
❑ This is known as white space collapsing;
❑ If you wanted to add a line break inside the middle of a paragraph or
between other HTML elements, you can use the line break tag <br>
or <br/>;
❑ To create a break between themes we can add a horizontal line using
<hr> or <hr/>.
HTML Text Formatting:
physical styles
Example:
❑ Example 2:
<ul type="circle">
<li>JavaScript</li>
<li>HTML</li>
<li>CSS</li>
</ul>
HTML Lists - Order List
❑ Example 2:
<ol type="a">
<li>Attend the lessons</li>
<li>Perform the lab exercises</li>
</ol>
HTML Links (Hyperlinks)
❑ By using hyperlinks, you can move automatically from a resource to another
— enabling the very idea of browsing or surfing.
❑ You will commonly come across the following types of links:
o Links from one website to another;
o Links from one page to another on the same website;
o Links from one part of a web page to another part of the same page;
o Links that open in a new browser window.
❑ The HTML tag identifying the presence of a link is named anchor and is
identified with <a> </a>.
Attribute Closing tag
❑ Links should indicate into which frame (or window) the target
page should be visualized:
o <a href="URL" target="name_of_the_frame">...</a>
❑ Special values for target:
o "_blank" (new window);
o "_self" (in the same frame) = default;
o "_top" (span the entire window).
General attributes
of HTML tags
❑ id= "string ":
o Anchor for a link;
o Reference to an element from a script;
o Reference to a field in a form;
o Reference for a specific style in CSS;
o Is unique.
❑ class = "class1 class2 … ":
o List of classes to be used e.g., as CSS selectors;
o HTML elements can have more than one class name;
o They are not unique.
❑ title = "title ":
o Visualized when pointing to the element
❑ lang = "language":
o For automatic text reading (values: en, it, fr, de …)
HTML Links: Examples
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title of the tab</title>
</head>
<body>
<h1 id="top">Top of the page</h1>
<h3>Links from one website to another</h3>
<a href="https://dominusoft.co/">Dominusoft</a>
<h3>Links from one page to another on the same website</h3>
<a href="about.html">About page</a>
<h3>Links from one part of a web page to another part of the same page</h3>
<a href="#top"> Go to the top of page</a>
<h3>Links that open in a new browser window</h3>
<a href="https://developer.mozilla.org/en-US/" target="_blank"> MDN </a>
</body>
</html>
HTML Images
❑ There are many reasons why you might want to add an image to a web
page: you might want to include a logo, photograph, illustration, diagram,
or chart.
<img src="file name or the path where the image is located" alt="a description of
image">
o src=“image.png” - Inserts the image contained in the file image.png.
o alt=“Picture of something” - Inserts the image, but if the browser does not
support graphics or fails to load the URL, It visualizes the text.
o Difference between linking and inserting an image:
• <img src="image.png"> - inserts the image inside the page;
• <a href="image.png"> - by following the link, you visit a page containing
only the image.
HTML Images
❑ Attributes:
o align= left / center / right;
o border= size;
o width= size;
o cellspacing= size;
o cellpadding=size;
o summary= text;
o frame= void / above / below / hsides / lhs / rhs / vsides / box / border.
HTML Table
❑ To build a table we need rows and columns:
o <tr> … </tr> - Table row, indicate the start of each row;
o Inside the row we find cells:
▪ <th> … </th> - Table heading, its purpose is to represent the
heading for either a column or a row;
▪ <td> … </td> - Table data, represent each cell of the table.
❑ Sometimes you may need the entries in a table to stretch across more than
one row or column:
o colspan = "number_of_columns " - The colspan attribute can be used on
a <th> or <td> element and indicates how many columns that cell should
run across ;
o rowspan = "number_of_rows " - The rowspan attribute can be used on a
<th> or <td> element and indicates how many rows that cell should span
down the table.
HTML Table: Example
<table border="2">
<tr>
<th></th>
<th>Web Design</th>
<th>Web Development</th>
<th>Graphic Design</th>
</tr>
<tr>
<th>11:00 - 13:00</th>
<td rowspan="2">Frontend</td>
<td>Frontend</td>
<td>Illustrator</td>
</tr>
<tr>
<th>17:00 - 19:00</th>
<td>Backend</td>
<td>Photoshop</td>
</tr>
</table>
HTML Long Table
❑ There are three elements that help distinguish between the main
content of the table and the first and last rows:
o <thead> … </thead> - Table head, the headings of the table;
o password;
o textarea (multi-line);
o check boxes (users can select and unselect one or more options);
o number;
o email;
o submit;
o file etc..
HTML Form Structure
❑ <form> … </form> - Where form controls stay:
o method="…" - Forms can be sent using one of two methods: get or
post;
o action="…" - Its value is the URL for the page on the server that will
receive the information in the form when it is submitted.
❑ <label> … </label> - Indicating the purpose of each:
o for="…" - Which form control the label belongs to.
❑ <input> … </input> - Where the user can enter data, most important form
element:
o type="…" - Type of input;
o id="…" - The same as the value of for;
o required – The field must be filled.
<form method="... " action="…">
<label for="…"></label>
<input type="…" id="…">
</form>
HTML Form Example
<form method="" action="POST">
<div>
<label for="username">Username</label>
<input type="" id="usename" required>
</div>
<div>
<label for="email">Email</label>
<input type="email" id="email" required>
</div>
<div>
<label for="password">Password</label>
<input type="password" id="password" required>
</div>
<div>
<label for="age">Age</label>
<input type="number" min="16" id="age" required>
</div>
<input type="submit">
</form>
HTML Form Select
❑ A dropdown list box (also known as a select box) allows users to select one
option from a dropdown list.
❑ <select>…</select> - It is used to create a dropdown list box;
o name = "…" - The name attribute indicates the name of the form
control being sent to the server, along with the value the user
selected.
❑ <option> … </option> - Is used to specify the options that the user can
select from:
o value = "…" - Is used to specify the options that the user can select
from.
<select name="..." id="...">
<option value="...">...</option>
<option value="...">...</option>
<option value="...">...</option>
<option value="...">...</option>
</select>
HTML Form Select: Example
❑ Audio Example:
o Example 1:
<audio src="audio.ogg" controls autoplay></audio>
o Example 2:
<audio controls>
<source src="audio.ogg" type="audio/ogg">
<source src="audio.mp3" type="audio/mpeg">
</audio>
HTML Video: Example
❑ Video Example:
o Example 1:
<video src="video.mp4" poster="image.jpg" width="400" height="300“ controls loop>
</video>
o Example 2:
<video width="320" height="240" controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
</video>
Questions?
www.dominusoft.co