3. What is HTML?
• HTML stands for Hyper Text Markup Language
• HTML is the standard markup language for creating
Web pages
• HTML describes the structure of a Web page
• HTML consists of a series of elements
• HTML elements tell the browser how to display the
content
• HTML elements label pieces of content such as "this is a
heading", "this is a paragraph", "this is a link", etc.
4. HTML Documents
All HTML documents must start with a document type declaration:
<!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>.
5. HTML Elements:
• The HTML element is everything from the start tag to
the end tag:
<tagname>Content goes here...</tagname>
6. HTML is Not Case Sensitive
• HTML tags are not case sensitive:
<P> means the same as <p>.
10. The <!DOCTYPE> Declaration
The <!DOCTYPE> declaration represents the document type, and helps
browsers to display web pages correctly.
It must only appear once, at the top of the page (before any HTML tags).
The <!DOCTYPE> declaration is not case sensitive.
The <!DOCTYPE> declaration for HTML5 is:
12. HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading.
<h6> defines the least important heading:
13. Example:
<!DOCTYPE html>
<html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
14. OUTPUT:
This is heading 1
This is heading 2
This is heading 3
This is heading 4
This is heading 5
This is heading 6
18. <pre>
• <pre> tag defines preformatted text.
• Text in a <pre> element is displayed in a fixed-width font, and the text
preserves both spaces and line breaks. The text will be displayed
exactly as written in the HTML source code.
20. Output:
The pre element
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks
21. HTML Links
HTML links are defined with the <a> tag:
<a href="https://www.annauniversity.com">
This is a link
</a>
22. WRAP BUTTON INSIDE LINK
<a href="https://code-boxx.com">
<button>Go to Previous</button>
</a>
23. • The link's destination is specified in the href attribute.
• Attributes are used to provide additional information about HTML
elements.
24. HTML Images
HTML images are defined with the <img> tag.
The source file (src), alternative text (alt), width, and height are
provided as attributes:
25. The alt Attribute
• The required alt attribute for the <img> tag specifies an alternate text
for an image,
• if the image for some reason cannot be displayed.
• This can be due to slow connection, or an error in the src attribute, or
if the user uses a screen reader.
26. The width and height Attributes
The <img> tag should also contain the width and height attributes,
which specifies the width and height of the image (in pixels):
<img src=“master.jpg" alt=“masterfilm.com" width="104"
height="142">
28. Background Image on a HTML element
• To add a background image on an HTML element, use the HTML style attribute
and the CSS background-image property:
29. <html>
<body>
<h2>Background Image</h2>
<p>A background image for a div element:</p>
<div style="background-image: url('img_girl.jpg');">
You can specify background images<br>
</div>
<p>A background image for a p element:</p>
<p style="background-image: url('img_girl.jpg');">
You can specify background images<br>
for any visible HTML element.<br>
</p>
</body>
30. Background Image on a Page
• If we want the entire page to have a background image, we must specify the
background image on the <body> element:
32. Background Repeat
• If the background image is smaller than the element, the image will repeat itself,
horizontally and vertically, until it reaches the end of the element:
36. Background Cover
• If we want the background image to cover the entire element, we can
set the background-size property to cover.
• Also, to make sure the entire element is always covered, set the
background-attachment property to fixed:
• This way, the background image will cover the entire element, with no
stretching (the image will keep its original proportions):
38. Background Stretch
• If we want the background image to stretch to fit the entire element,
we can set the background-size property to 100% 100%:
• Try resizing the browser window, and we will see that the image will
stretch, but always cover the entire element.
39. <html>
<head>
<style>
body {
background-image: url('img_girl.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
</head>
<body>
<h2>Background Stretch</h2>
<p>Set the background-size property to "100% 100%" and the background image will be stretched to cover the entire element, in this case the
body element.</p>
</body>
</html>
40. The style Attribute
• The style attribute is used to add styles to an element, such as color,
font, size, and more.
41. Example:
<!DOCTYPE html>
<html>
<body>
<h2>The style Attribute</h2>
<p>The style attribute is used to add styles to an element, such as color:</p>
<p style="color:red;">This is a red paragraph.</p>
</body>
</html>
42. The title Attribute
The title attribute defines some extra information about an element.
The value of the title attribute will be displayed as a tooltip when you
mouse over the element:
43. <html>
<body>
<h2 title="I'm a header">The title Attribute</h2>
<p title="I'm a tooltip">Mouse over this paragraph, to display the title
attribute as a tooltip.</p>
</body>
</html>
44. The lang Attribute
• We should always include the lang attribute inside the <html> tag, to
declare the language of the Web page.
• This is meant to assist search engines and browsers.
46. • Country codes can also be added to the language code in the lang
attribute. So, the first two characters define the language of the
HTML page, and the last two characters define the country.
48. All HTML elements can have attributes
The href attribute of <a> specifies the URL of the page the link goes to
The src attribute of <img> specifies the path to the image to be displayed
The width and height attributes of <img> provide size information for images
The alt attribute of <img> provides an alternate text for an image
The style attribute is used to add styles to an element, such as color, font,
size, and more
The lang attribute of the <html> tag declares the language of the Web page
The title attribute defines some extra information about an element
49. HTML Text Formatting
• HTML contains several elements for defining text with a
special meaning.
Example
This text is bold
This text is italic
This is subscript and superscript
50. HTML Formatting Elements
HTML Formatting Elements
Formatting elements were designed to display special types of text:
<b> - Bold text
<strong> - Important text
<i> - Italic text
<em> - Emphasized text
<mark> - Marked text
<small> - Smaller text
<del> - Deleted text
<ins> - Inserted text
<sub> - Subscript text
<sup> - Superscript text
51. HTML <b> and <strong> Elements
• The HTML <b> element defines bold text, without any extra
importance.
<b>This text is bold</b>
52. • The HTML <strong> element defines text with strong importance. The
content inside is typically displayed in bold.
<strong>This text is important!</strong>
53. HTML <i> Tag
• The <i> tag defines a part of text in an alternate voice or mood.
• The content inside is typically displayed in italic.
62. HTML Lists
• HTML lists allow web developers to group a set of related items in lists.
Example
An unordered HTML list:
• Item
• Item
• Item
• Item
An ordered HTML list:
1.First item
2.Second item
3.Third item
4.Fourth item
63. Unordered HTML List
• An unordered list starts with the <ul> tag. Each list item starts with
the <li> tag.
• The list items will be marked with bullets (small black circles) by
default:
66. Ordered HTML List
• An ordered list starts with the <ol> tag. Each list item starts with the
<li> tag.
• The list items will be marked with numbers by default:
69. HTML Description Lists
HTML also supports description lists.
A description list is a list of terms, with a description of each term.
The <dl> tag defines the description list,
the <dt> tag defines the term (name),
the <dd> tag describes each term:
72. Define an HTML Table
• The <table> tag defines an HTML table.
• Each table row is defined with a <tr> tag. Each table header is defined
with a <th> tag. Each table data/cell is defined with a <td> tag.
• By default, the text in <th> elements are bold and centered.
• By default, the text in <td> elements are regular and left-aligned.
83. Non-breaking Space
A commonly used entity in HTML is the non-breaking space:
A non-breaking space is a space that will not break into a new line.
Two words separated by a non-breaking space will stick together (not break into a new line). This is handy when breaking the words
might be disruptive.
Examples:
§ 10
10 km/h
10 PM
Another common use of the non-breaking space is to prevent browsers from truncating 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
character entity.