HTML_Om
HTML_Om
HTML (HyperText Markup Language) is the foundation of web development. It consists of tags
that define the structure, content, and presentation of web pages. Tags are enclosed in angle
brackets (<>) and usually come in pairs: an opening tag (<tag>) and a closing tag (</tag>).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Document</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>This is a basic HTML structure.</p>
</body>
</html>
1. <!DOCTYPE html>:
o Declares the document type and version of HTML being used (HTML5).
o Helps the browser render the page correctly.
2. <html lang="en">:
o The <html> tag is the root element of an HTML document.
o The lang="en" attribute specifies the language of the document's content as
English. This is important for accessibility and SEO.
3. <head>:
o Contains meta-information about the document, such as character encoding,
viewport settings, title, and links to external resources like CSS or JavaScript
files.
a. <meta charset="UTF-8">:
o Ensures the page is responsive by setting the width to the device's screen size and
the initial zoom level to 1.0.
c. <title>HTML Document</title>:
o Defines the title of the webpage. This title appears on the browser tab and in
search engine results.
4. <body>:
o Contains the content of the HTML document that is visible to users in the
browser.
a. <h1>:
b. <p>:
o Defines a paragraph. The content within the tags ("This is a basic HTML
structure.") is the paragraph text.
Visual Studio Code (VS Code) provides a built-in shortcut to generate the basic HTML structure
instantly:
1. Steps:
o Open a new file in VS Code.
o Save the file with a .html extension (e.g., index.html).
o Type ! (exclamation mark) and press Tab or Enter.
2. Result: This will auto-generate the following HTML boilerplate:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
3. Customization:
o Replace "Document" in the <title> tag with your desired page title.
o Add your content inside the <body> tag.
<div>
<p>Nested content</p>
</div>
<p>Correct</p>
5. Avoid Deprecated Tags: Do not use outdated tags like <font>; instead, use CSS for
styling.
Block elements are fundamental in HTML because they structure the layout of a webpage. These
elements are designed to start on a new line and typically extend across the full width of their
container. They are ideal for creating larger sections of content like paragraphs, headings, and
containers.
• Purpose: The <div> element is a generic container used to group content or elements
together. It has no semantic meaning by itself, but it is widely used for layout and styling
purposes.
• Common Use Cases:
o Grouping related elements for styling with CSS.
o Creating sections within a webpage.
Example:
<div>
<h1>Block Element</h1>
<p>This is a paragraph inside a div.</p>
</div>
• Explanation:
o The <div> groups the <h1> and <p> tags together.
o Useful for applying shared styles or JavaScript functionality to these elements.
• Purpose: The <header> element is used to define the introductory section of a webpage
or a section. It typically contains headings, navigation menus, or logos.
• Common Use Cases:
o Placing a website’s title or branding.
o Adding a navigation bar.
Example:
<header>
<h1>Website Title</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</nav>
</header>
• Explanation:
o The <header> groups the title and navigation links.
o Helps search engines understand the introductory content of a page or section.
• Purpose: The <section> element groups related content within a webpage. It is often
used for dividing content into sections, each with its own theme.
• Common Use Cases:
o Grouping "About Us" or "Services" content on a webpage.
o Creating visually distinct sections in a webpage.
Example:
<section>
<h2>About Us</h2>
<p>We are a global company dedicated to innovation.</p>
</section>
• Explanation:
o The <section> groups the heading and paragraph into a single thematic block.
o Makes the page more structured and improves readability.
• Purpose: The <article> element is used for self-contained, reusable content such as
blog posts, news articles, or user-generated comments.
• Common Use Cases:
o Blog posts.
o News or magazine articles.
o Forum posts.
Example:
<article>
<h2>Blog Post</h2>
<p>This is an article about web development trends in 2025.</p>
</article>
• Explanation:
o The <article> groups the heading and paragraph, indicating they belong
together as a single, self-contained item.
o Can be syndicated or shared independently of the rest of the webpage.
• Purpose: The <footer> element is used to define the footer section of a webpage or a
section. It typically contains copyright information, links, or contact details.
• Common Use Cases:
o Adding legal information like copyrights.
o Placing contact details or navigation links.
Example:
<footer>
<p>© 2025 My Website</p>
<p>Contact us: <a
href="mailto:[email protected]">[email protected]</a></p>
</footer>
• Explanation:
o The <footer> defines the end of a webpage or section.
o Commonly used for supplemental information relevant to the entire page or a
specific section.
1. Structure: They divide the content into logical sections, making it easier to read and
navigate.
2. Semantic Meaning: Elements like <header>, <footer>, <article>, and <section>
provide semantic context, which improves SEO and accessibility.
3. Styling: Block elements provide a foundation for applying styles via CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Website Structure</title>
</head>
<body>
<header>
<h1>My Website</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<section id="about">
<h2>About Us</h2>
<p>We are a global leader in technology solutions.</p>
</section>
<article>
<h2>Latest Blog Post</h2>
<p>Explore the top web development trends in 2025!</p>
</article>
<footer>
<p>© 2025 My Website | All Rights Reserved</p>
</footer>
</body>
</html>
• Result: The webpage is cleanly divided into distinct sections, making it easy to navigate
and understand. Each block element contributes to the structure and organization of the
page.
Text elements in HTML are inline elements used to define, format, or emphasize text. These
elements enhance the readability of the content and provide semantic meaning to different parts
of the text.
1. <p>: Paragraph
Example:
<p>This is a paragraph.</p>
• Explanation: The <p> element groups text into logical units, making the content easier to
read and visually appealing.
• Purpose: Marks text with strong importance, typically displayed as bold text.
• Semantic Meaning:
o It implies importance or urgency, rather than just visual styling.
Example:
<p>This is <strong>important</strong> text.</p>
• Explanation: The <strong> element not only bolds the text but also provides semantic
emphasis for screen readers or search engines.
Example:
• Explanation: The <em> element can help highlight specific parts of a sentence where
emphasis is required.
Example:
• Explanation: The <span> element is used here to change the color of the word "red"
without affecting other parts of the text.
Example:
<p>This is <mark>highlighted</mark> text.</p>
• Explanation: The <mark> element is visually distinct, making important text stand out to
readers.
These elements are designed for displaying programming-related content in a readable and
semantically meaningful way.
Example:
• Purpose: Preserves whitespace, line breaks, and indentation exactly as written in the
code.
• Characteristics:
o Often used for displaying blocks of code.
Example:
<pre>
Line 1
Line 2 (indented)
</pre>
• Explanation: The <pre> element displays text as-is, making it suitable for code blocks or
ASCII art.
3. <kbd>: Keyboard Input
Example:
Example:
• Explanation: The <samp> element helps distinguish program outputs from regular text.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text and Code Elements</title>
</head>
<body>
<p>This is a basic paragraph with <strong>important</strong> and
<em>emphasized</em> text.</p>
• Result:
o Paragraphs show different types of emphasized text.
o Inline and block code elements are displayed with proper formatting.
o Highlights and user inputs are visually distinct.
<section>
<article>
<h2>Block Elements</h2>
<div>
<p>This is a block element example.</p>
</div>
</article>
<article>
<h2>Text Elements</h2>
<p>This text is <strong>bold</strong> and <em>italic</em>.</p>
<p class="highlight">Highlighted text using CSS.</p>
</article>
<article>
<h2>Code Elements</h2>
<p>Inline code: <code>let x = 10;</code></p>
<pre>
function hello() {
console.log("Hello, World!");
}
</pre>
<p>Keyboard shortcut: <kbd>Ctrl</kbd> + <kbd>Alt</kbd> +
<kbd>Del</kbd></p>
</article>
</section>
<footer>
<p>© 2025 Your Website</p>
</footer>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>HTML Entity Example</h1>
<h2>The characters are: < > ≤ ½ ¼ &</h2>
</body>
</html>
List
HTML lists allow web developers to group a set of related items in lists.
Types:
ordered list
1. An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
2. The list items will be marked with numbers by default
unordered list
● A list that does not order its items by letter or number
● An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
● The list items will be marked with bullets (disc) by default
Unordered List
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>Unordered list</title>
</head>
<body>
<h1> My favorite drinking items </h1>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<ul type="circle">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<ul type="square">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
Ordered list
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>Ordered list</title>
</head>
<body>
<h1> My favorite drinking items </h1>
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol type="i">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
Nested list
● Lists may be nested to represent hierarchical relationships, as in a multilevel outline
● A nested list is simply a list that occurs as an element of another list
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>nested list</title>
</head>
<body>
<h1> My favorite items </h1>
<ol>
<li>Food items
<ul><li>biriyani</li>
<li>dosai</li>
<li>chicken rice</li>
</ul>
</li>
<li>Drinking items
<ul><li>coffee</li>
<li>tea</li>
<li>milk</li>
</ul>
</li>
</ol>
</body>
</html>
Linking(hyperlink)
● One of the most important HTML5 features is the hyperlink, which references (or links to) other resources,
such as HTML5 documents and images.
● Web browsers typically underline text hyperlinks and color their text blue by default
● Links are created using the a (anchor) element.
● It defines a hyperlink to the URL assigned to attribute href (hypertext reference), which specifies a
resource’s location, such as
○ a web page or location within a web page
○ a file
○ an e-mail address
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>Image</title>
</head>
<body>
<h1>Here are my favorite sites:</h1>
<strong>Click a name to visit that site.</strong><br>
<a href = "http://www.facebook.com">Facebook</a><br>
<a href = "http://www.twitter.com">twitter</a><br>
<a href = "http://www.google.com">google</a><br>
Hyperlinking to an E-Mail Address
<a href = "mailto:[email protected]">mail</a>
Link to webpage
<a href = "image.html">click</a>
Using Images as Hyperlinks
<img src = "tajmahal.jpg" width = "300" height = "300" alt = "tajmahal"/>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>nav</title>
</head>
<body>
<h1>The nav element</h1>
<h2>The nav element defines a set of navigation links:</h2>
<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/python/">Python</a>
</nav>
</body>
</html>
Internal Linking
● Internal linking—a mechanism that enables the user to jump between locations in the
same document.
● Internal linking is useful for long documents that contain many sections.
● Clicking an internal link enables the user to find a section without scrolling through the
entire document.
<!DOCTYPE html>
<html>
<head><meta charset = "utf-8">
<title>Internal linking</title>
</head>
<body>
<img src="internet.jpg" height="200" width="200">
<h1 id = "features">The Best Features of the Internet</h1>
<a href = "#drawbacks">Go to Drawbacks of Internet</a>
<ul>
<li>You can meet people from countries around the world.</li>
<li>You have access to new media as it becomes public:
<ul>
<li>New games</li>
<li>New applications
<ul>
<li>For Business</li>
<li>For Pleasure</li>
</ul>
</li>
<li>Around the clock news</li>
<li>Search Engines</li>
<li>Shopping</li>
<li>Programming
<ul>
<li>HTML5</li>
<li>Java</li>
<li>Dynamic HTML</li>
<li>Scripts</li>
<li>New languages</li>
</ul>
</li>
</ul>
</li>
<li>Links</li>
<li>Keeping in touch with old friends</li>
<li>It is the technology of the future!</li>
<li>Extension of Existing IT Technology.</li>
<li>Flexibility of Communication</li>
<li>Security</li>
<li>Low Cost</li>
</ul>
<h1 id = "drawbacks">Drawbacks of Internet</h1>
<a href = "#features">Go to Favorite Features </a>
<ol>
<li>Addiction, time-waster, and causes distractions</li>
<li>Health issues and obesity.</li>
<li>Cyberbullying</li>
</ol>
</body>
</html>
● HTML frames are used to divide your browser window into multiple sections where each
section can load a separate HTML document.
● Instead of using body tag, use frameset tag in HTML to use frames in web browser. But
this Tag is deprecated in HTML 5.
● Each frame is indicated by frame tag and it basically defines which HTML document
shall open into the frame
● To define the horizontal frames use row attribute of frame tag in HTML document and to
define the vertical frames use col attribute of frame tag in HTML document.
<!DOCTYPE html>
<html>
<frameset cols="50%,50%">
<frame src="form.html" name="left">
<frameset rows="50%,50%">
<frame src="ol.html" name="right1">
<frame src="ul.html" name="right2">
</frameset>
</frameset>
</html>
IFrame
• An iFrame is an inline frame used inside a webpage to load another HTML document
inside it.
• It allows you to open new document inside the main browser's window. Inline frame
is also called floating frame.
!DOCTYPE html>
<html>
<head>
<title>welcome</title>
</head>
<body>
</body>
</html>
● blockquote element(<blockquote>)
○ HTML <blockquote> tag is used to define a block of text which is quoted from
another source. The Browser usually displays the content within <blockquote> tag as
indented text.
○ cite-It is used to specify the URL of the source from where the quote is taken.
FORM
1. <form>
• Purpose: Defines the form and acts as a container for input elements.
• Attributes:
o action: The URL where the form data is sent after submission.
o method: HTTP method (POST or GET) used to send data.
2. <input>
Used for various types of user inputs. The type attribute defines the specific input behavior.
Example:
Checkbox (type="checkbox")
Example:
Example:
Example:
3. <select> (Dropdown)
Example:
4. <textarea>
Example:
5. <button>
Example:
Example:
7. <fieldset> (Optional)
Example:
<fieldset>
<legend>Personal Details</legend>
<input type="text" name="firstName">
</fieldset>
8. <datalist> (Optional)
Example: