0% found this document useful (0 votes)
14 views13 pages

HTML Document Structure Basics

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views13 pages

HTML Document Structure Basics

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

HTML <Hyper Text Markup Language>

Step 1: Open Notepad (Window)


Step 1: Open TextEdit (Mac)
Step 2: Write Some HTML in the Notepad.
Step 3: Save the HTML Page on your computer with the extension of “.html “
Step 4: View the HTML Page in Your Browser.

Head of Web page

Body of Web page

All HTML documents are divided into two main parts: the head and the body. It also has
four primary tags: <html>, <head>, <title> and <body>. See fig.1
HTML tags are element names surrounded by angle brackets. HTML tags normally come
in pairs like <p> and </p>.
The first tag in a pair is the start tag, the second tag is the end tag.
The end tag is written like the start tag, but with a forward slash inserted before the tag
name.
The start tag is also called the opening tag, and the end tag the closing tag.
<html>…</html>
Every HTML document begins and ends with the <html> tag. This tells the browser
that the following document is an html file.
<head>…</head>
The <head> tag contains the title of the document along with general information
about the file, like the author, copyright, keywords and/or a description of what appears on
the page.

1
<title>…</title>
Appears within the <head> tags and gives the title of the page. Try to make your titles
descriptive, but not more than 20 words in length. The title appears at the very top of the
browser page on the title tab.
<body>…</body>
The main content of your page is placed within the body tags: your text, images, links,
tables and so on.
<!DOCTYPE html> declaration defines this document to be HTML5

1. Structure of HTML

Fig:1

2. <meta> Element
The <meta> element is used to specify which character set is used, page description,
keywords, author, and other metadata.
Metadata is used by browsers (how to display content), by search engines (keywords),
and other web services.
 Define the character set used:
<meta charset="UTF-8"> The default character set in HTML 5 is UTF-8.
 Define a description of your web page:
<meta name="description" content="Free Web tutorials">
 Define keywords for search engines:
<meta name="keywords" content="HTML, CSS, XML, JavaScript">
 Define the author of a page:
<meta name="author" content="John Doe">
 Refresh document every 30 seconds:
<meta http-equiv="refresh" content="30">
 Define viewport element in all your web pages:

2
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="John Doe">
</head>
<body>
<p>All meta information goes before the body. 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>
</body>
</html>

Horizontal Rules
The <hr/> tag defines a thematic break in an HTML page, and is most often displayed
as a horizontal rule. <hr color=red size=3 width=75%>

Line Breaks
The HTML <br> element defines a line break.
Use <br> if you want a line break (a new line) without starting a new paragraph:

Style Attribute
Setting the style of an HTML element, can be done with the style attribute.
<tagname style="property:value;">
 Background Color
<body bgcolor=blue>
<body style="background-color:powderblue;">
 Text Color
<h1 font color=red> <h1 style="color:blue;">
<font color=yellow> <p style="color:red;">
 Fonts
<h1 font face=book Antiqua> <h1 style="font-family:verdana;">
<font face=book Antiqua> <p style="font-family:courier;">

3
 Text Size
<h1 style="font-size:300%;">
<font size=6> <p style="font-size:160%;">
 Text Alignment {centre,right}
<h1 style="text-align:center;">
<font align=center> <p style="text-align:center;">

6. Formatting Elements
 <b> - Bold text
 <strong> - Important text
 <i> - Italic text
 <u> - Underline text
 <em> - Emphasized text
 <mark> - Marked text {Highlight color}
 <small> - Small text
 <del> - Deleted text
 <ins> - Inserted text
 <sub> - Subscript text
 <sup> - Superscript text
 <strike> - Strikethrough text

7. Color Names

Example:
<h1 style="background-color:DodgerBlue;">
<p style="background-color:Tomato;">

8. Border Color

4
Example:
<h1 style="border:2px solid Tomato;">
<h1 style="border:2px solid DodgerBlue;">
<h1 style="border:2px solid Violet;">
<p style=”color:orange;border-width:10px;border-style:sold;border-color:green;”>

Language

<html lang="en">
...
</html>

Heading

h1

h2

h3
h4
h5
h6

<h1> defines the most important heading. <h6> defines the least important heading.

List

There are three types of lists in HTML.


(1) Ordered list (Numbered items) <ol>  1,2,3,…….
<ol type= > (2) Unordered list (Bulleted items)
<li> </li> <ul type= >
<li> </li> <li> </li>
<li> </li> <li> </li>
<li> </li>
Type=A  A,B,C,….
Type=a  a,b,c,….. Type= disc  
Type=I  I,II,III,…… Type= circle  
Type= square  

5
(3) Definition list (A list of items, with a description of each item)

<dl> definition list


<dt> (defines terms/names)
<dd> (describes each term/name)

Nested HTML Lists


<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>

List on a Specific Number


< ol Start = “ “>

Exercises
(I) Write the HTML coding for the following printing format.
1. Chapter One 1. Item A
 Section One
 Section Two
2. Item B
 Section Three  Subitem B.1
2. Chapter Two  Subitem B.2
3. Chapter Three
3. Item C

6
Tables
Table is defined with the <table> tag.
Eg: <table style="width:100%">

Each table row is defined with the <tr> tag.


A table header is defined with the <th> tag. By default, table headings are bold and
centered.
A table data/cell is defined with the <td> tag. The <td> elements are the data
containers of the table. They can contain all sorts of HTML elements; text, images, lists,
other tables, etc.
<table> to declare a table
</table> to end the table
<th> to declare the start of header cell in bold
</th> to declare the end of header cell in bold
<tr> to declare the start of new row
</tr> to declare the end of new row
<td> to declare a cell
</td> to close a cell

Eg:
<!DOCTYPE html>
<html>
<body>
<h2>Basic HTML Table</h2>

<table style="width:100%;">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>

7
<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 with cell spacing

<table border=1>
<tr align=center bgcolor=orange>
<td rowspan=3 align=center> Title goes here</td>
<td width=50> A </td>
<td width=50> D </td>
</tr>
<tr align=center>
<td width=50> B </td>
<td width=50> E </td>
</tr>
<tr align=center>
<td width=50> C </td>
<td width=50> F </td>
</tr>
</table>

Movind Text with Marquee


<marquee behavior=alternate direction=right/left/up/down>
</marquee>

Eg:
<marquee> Hello IIP !! </marquee>

<Marquee width=200 Height=50> Howdy! </marquee>

8
BEHAVIOR=ALTERNATE makes the content bounce back and forth, all of it remaining
visible all the time

<marquee behavior=alternate direction=up>

BEHAVIOR=SCROLL, which is the default, indicates that the content should scroll off the
edge of the marquee area, then reappear on the other side.

<marquee behavior=scroll> Have a Good Day!!! </marquee>

SCROLLDELAY, together with SCROLLAMOUNT, sets the speed of the scrolling.


SCROLLDELAY sets the amount of delay in milliseconds (a millisecond is 1/1000th of a
second). The default delay is 85.

<marquee scrolldelay=500> Good Friendship *** </marquee>

SCROLLAMOUNT sets the size in pixels of each jump. A higher value


for SCROLLAMOUNT makes the marquee scroll faster. The default value is 6.

<marquee scrollamount=50> HELLO </marquee>

BEHAVIOR=SLIDE is the contents stop scrolling as soon as the reaches the left side.

<marquee behavior=slide> Morning@@@</marquee>

BGCOLOR sets the background color of the marquee.


<marquee bgcolor=blue> GOOD DAY </marquee>

HSPACE sets the horizontal space to the left and right of the marquee. VSPACE sets the
vertical space at the top and bottom of the marquee.

<marquee hspace=50 width=”25%” bgcolor=yellow><p> HOWDY THERE !</p> <p>


Good to see ya!</p><p> Hi There!</p> </marquee>

Hello.<marquee vspace=50 bgcolor=green> HOWDY THERE </marquee>


<marquee style=”font-family:Book Antiqua; color:#FFFFFF” bgcolor=”#000080”
direction=”up” height=”80”> This is an example of Marquee
direction</marquee>

Adding images to web pages

<img src="location of the file\filename">

The alt attribute is also useful if the image cannot be displayed (e.g. if it does not exist):

<img src="img_girl.jpg" alt="Girl with a jacket">

9
Preparing audio and video

Before HTML5, audio or video could only be played in a browser with a plug-in (like
flash).

The HTML5 <video> element specifies a standard way to embed a video in a web
page. To show a video in HTML, use the <video> element:

<video width="320" height="240" controls>


<source src="movie.mp4" type="video/mp4">
</video>

Autoplay - Specifies that the video will start playing as soon as it is ready.
Loop - Specifies that the video will start over again, every time it is finished
Muted - Specifies that the audio output of the video should be muted

Eg:

<!DOCTYPE html>
<html>
<body>
<video controls autoplay muted width="400">
<source src="C:\Users\User\Desktop\
2015_04_Vocational_training_movie_with_questions.mp4" type="video/mp4">
</video>
<p>

Video courtesy of
<a href="[Link] target="_blank">Myo
Gyi</a>.
<a href="C:\Users\User\Desktop\Thardilu.mp4" target=_blank> Click here to watch video
file !!</a>
</p>

</body>
</html>

Audio File
To play an audio file in HTML, use the <audio> element:

<audio controls>
<source src="horse.mp3" type="audio/mp3">
</audio>

Eg:

10
<!DOCTYPE html>
<html>
<body>

<audio controls loop>


<source src="ae_thel_tin_zar_maw.mp3" type="audio/mp3">
</audio>

</body>
</html>

Links with CSS and HTML

<link rel="stylesheet" href="[Link]">

Links

Hyperlinks are defined with the HTML <a> tag:


<a href="url">link text</a>

Link Titles

<a href="Name of the page" title="title name">Testing of link title</a>

Email Link
<a href=”[Link] address”>----------------</a>

Inline frames
<iframe src="URL"></iframe>
<iframe src="demo_iframe.htm" height="200" width="300"></iframe>

11
Table grouping with Style

The <thead> tag is used to group header content in an HTML [Link] <thead> element is
used in conjunction with the <tbody> and <tfoot> elements to specify each part of a table
(header, body, footer).

Eg:
<!DOCTYPE html>
<html>
<head>
<style>
thead {color:green;}
tbody {color:blue;}
tfoot {color:red;}

table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Sum</td>
<td>$180</td>
</tr>
</tfoot>
</table>

<p><b>Tip:</b> The thead, tbody, and tfoot elements will not affect the layout of the table
by default. However, you can use CSS to style these elements.</p>
</body>
</html>

12
Navigation <nav>

Element represents a section of a page whose purpose is to provide navigation links,


either within the current document or to other documents.

Eg:
<!DOCTYPE html>
<html>
<head>
<title>nav tag</title>
<style>
nav {
border:2px solid red;
background-color:Yellow;
padding:8px;
width:50%;
}
</style>
</head>
<body><center>
<nav>
<a href = "#">Home</a>
<a href = "#">Interview</a>
<a href = "#">Languages</a>
<a href = "#">Data Structure</a>
<a href = "#">Algorithm</a>
</nav>
</center></body> </html>

13

Common questions

Powered by AI

Different heading tags in HTML, such as <h1> through <h6>, are used to create a structured hierarchy of content on a webpage. The <h1> tag defines the most important heading, typically used for the main title, while <h6> defines the least important heading, used for subheadings. This hierarchical structure is crucial for readability and accessibility, as it helps both users and search engines understand the organization of content. For example, search engines assign more weight to content found in <h1> tags, which can influence SEO. Additionally, screen readers use these tags to help visually impaired users navigate the page .

The <iframe> element in HTML is used to embed another HTML document within the current page, allowing for integration of external content like videos, maps, or other webpages. This capability facilitates dynamic content addition without altering the main document structure. However, considerations include ensuring the security of included content to avoid vulnerabilities such as XSS attacks, configuring cross-origin resource sharing (CORS) appropriately, and being mindful of load performance and user engagement, as multiple iframes can slow down loading time and affect SEO negatively .

HTML meta tags within the head section are used to provide metadata about the HTML document. This metadata can specify the character set used, page description, keywords, author, and other information that can help browsers in displaying the content, and search engines in indexing and ranking the page. For example, the <meta name='description'> tag provides a brief description of the page content that can appear in search results, which can affect click-through rates. Similarly, <meta name='keywords'> helps in search engine optimization by defining the relevant keywords for the page. Thus, meta tags are crucial for both performance and visibility of web pages .

The <video> element in HTML5 provides a standard way to embed video content directly in web pages without requiring external plugins like Flash, which was the norm before HTML5. This element supports different video formats and attributes such as controls, autoplay, muted, and loop, allowing for broad compatibility and playback customization. The significance lies in improving accessibility and user experience by providing a uniform API across browsers, increasing the reliability and security of video playback, and facilitating responsive design through attributes like width and height .

Character sets and encoding specifications in HTML5 define how text is represented and rendered, ensuring that content displays correctly across different browsers and devices. UTF-8 is the preferred character set as it covers a wide range of characters from different languages and symbols, allowing for the consistent representation of international content. UTF-8's backward compatibility with ASCII and its efficiency in encoding typical text data make it a versatile and reliable choice, reducing encoding-related errors and enhancing user experience globally .

The style attribute in HTML allows inline styling of elements, affecting how they are displayed without the need for separate CSS files. This attribute can modify the presentation of text elements by setting properties such as background color, text color, font family, size, and alignment. For example, <p style='color:red;'> would change the text color to red, and <h1 style='text-align:center;'> would center-align the heading. The implications for web design include increased flexibility and speed in styling elements, but also potential issues with maintainability and performance, as excessive inline styles can clutter HTML and make bulk updates challenging. Using CSS is generally recommended for consistency across a site and separation of content from presentation .

The HTML marquee element allows text to scroll or move across the webpage. Attributes such as behavior (scroll, slide, alternate), direction (left, right, up, down), and speed (controlled by scrolldelay and scrollamount) dictate how text is displayed. For example, behavior='alternate' makes the text bounce, while scrollamount and scrolldelay control the speed of movement. Although the marquee element can add dynamism to a site, it often affects usability and accessibility negatively, as it can be distracting and hard for screen readers to interpret. Thus, its use is generally discouraged in favor of CSS animations which offer more control and better compatibility with modern web standards .

An HTML table is structured with the <table> element, and consists of <tr> (table rows), <th> (table headers), and <td> (table data cells) elements. <th> elements are used to define headings for columns and are typically bold and centered. Tables can be customized to improve design and functionality by using attributes like border, cellpadding, and cellspacing, or CSS styles. For instance, a border can be added with <table border='1'> to enhance clarity, and cellpadding can influence cell padding. CSS can further control the presentation, such as setting alternate row colors for better readability. These customizations enhance the clarity, accessibility, and aesthetic appeal of data presentation on webpages .

The <nav> element in HTML5 is used to group navigation links, signifying to browsers and screen readers that its contents are intended for navigation. This semantically enriches the markup, enhancing the understanding of webpage structure. It supports the semantic web by clearly defining the navigation area, improving SEO through better machine readability, and aiding accessibility by allowing assistive technologies to skip directly to the navigation menu, facilitating quicker and more efficient interaction for users with disabilities .

Ordered lists (<ol>) in HTML present items in a numbered sequence, ideal for step-by-step instructions or ranking. Unordered lists (<ul>) use bullet points, suitable for lists where sequence does not matter, such as item inventories. Definition lists (<dl>) pair terms (<dt>) with descriptions (<dd>), useful for glossaries or FAQs. These list types serve different organizational purposes by visually conveying relationships and importance, helping users to quickly understand the list's intent on a webpage, and improve SEO by structuring content with semantic HTML tags .

You might also like