WD_CHAP3
WD_CHAP3
HTML (HyperText Markup Language) is the standard language used to create and design web pages. It structures
web content and allows browsers to display text, images, videos, and other elements on a web page. HTML forms
the foundation of every website and is often paired with CSS (Cascading Style Sheets) for styling and JavaScript for
interactivity.
Key Features of HTML:
1.Markup Language: HTML uses a system of tags to mark elements of content, defining their role and structure on
the page.
2.Platform-Independent: HTML documents can be viewed on any device or operating system that supports a web
browser.
3.Extensible: While HTML provides core tags, developers can use frameworks or integrate custom elements with
modern web standards.
Web Development: Introduction to HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport"
content="width=device-width, initial-scale=1.0"> <title>My First Webpage</title> </head> <body> <h1>Welcome
to My Webpage</h1> <p>This is a paragraph of text on my webpage.</p> </body> </html>
Explanation of the Code:<!DOCTYPE html>: Declares the document type as HTML5.<html>: The root element
containing all other HTML elements.<head>: Contains metadata about the webpage (like title, charset, and
viewport settings).<title>: Sets the title of the webpage, displayed in the browser tab.<body>: Contains the
content displayed on the webpage, such as headings, paragraphs, images, and more.
Web Development: Introduction to HTML
HTML Attributes:Attributes provide additional information about HTML elements. They are written within the
opening tag and usually follow the format: attribute="value".Example:htmlCopy code<a
href="https://example.com" target="_blank">Visit Example</a>href: Specifies the URL of the link.target="_blank":
Opens the link in a new tab.Modern HTML Practices:Semantic Elements: Use elements like <header>, <footer>,
<article>, and <section> for better structure and accessibility.Responsive Design: Combine HTML with CSS media
queries to create layouts that adapt to different screen sizes.Accessibility: Add attributes like alt for images and
aria-* for interactive components to make websites usable for everyone.HTML is the stepping stone for web
development. By mastering its structure and syntax, you can build websites and create a strong foundation for
learning advanced technologies like CSS, JavaScript, and backend frameworks.
Hypertext and HTML
Hypertext refers to a system of linking information through clickable references, enabling users to navigate
seamlessly from one piece of information to another. It’s the foundation of the World Wide Web, making it
possible to connect documents, media, and resources through links.
Key Characteristics of Hypertext:
1.Non-linear Navigation: Unlike traditional text, hypertext allows users to jump between topics or resources
through hyperlinks.
2.Dynamic Interactivity: Hypertext creates an interactive experience, guiding users to related information with a
single click.
3.Cross-referencing: Hyperlinks connect various pieces of content, enabling easy access to related material.
<a href="https://example.com">Visit Example Website</a>
Hypertext and HTML
HTML (HyperText Markup Language) is the language used to create web pages and structure content for the web.
It utilizes the concept of hypertext by allowing developers to embed hyperlinks within a document, creating a
network of interconnected resources.
Relationship Between Hypertext and HTML:
•Hypertext: The concept or system for linking documents.
•HTML: The technology used to implement hypertext on the web.
•For instance:Hypertext is the idea that you can click on the words "Contact Us" and be taken to a new page with
contact details.HTML provides the syntax (<a href="contact.html">Contact Us</a>) to make that link functional.
Hypertext and HTML
Links to External Pages:<a href="https://example.com">External Link</a>
Links to Internal Sections: <a href="#section1">Jump to Section 1</a> <h2 id="section1">Section 1</h2>
Interactive Navigation: Enables the creation of menus, breadcrumbs, and other navigation tools using links.
Embedding Media: Hypertext in HTML can connect to not just other pages but also multimedia like videos,
images, and documents.
Importance of Hypertext in HTML:
•Web Connectivity: Without hypertext, the web would lose its interactive and interconnected nature.
•User Experience: Hypertext-driven navigation simplifies how users discover and consume content.
•Efficiency: Makes vast information easily accessible and navigable.
In summary, hypertext is the concept, and HTML is the tool that brings this concept to life on the web, forming
the backbone of how we browse and interact with online content.
HTML Document Features
Structure and Layout: HTML provides the foundational structure of a webpage, defining elements like headings,
paragraphs, lists, and divisions for content organization.
Hyperlinks:HTML supports hyperlinks, enabling navigation between web pages or external resources using <a>
tags.
Multimedia Integration:HTML allows embedding multimedia content such as images (<img>), audio (<audio>),
and video (<video>).
Forms and Input:HTML supports creating interactive forms for user input using elements like <form>, <input>,
<textarea>, and <button>.
Semantics:Semantic elements like <header>, <footer>, <article>, and <section> provide meaningful structure and
improve accessibility and SEO.
Styling and Scripting Support:HTML can link with CSS for styling and JavaScript for dynamic behavior, enhancing
the design and functionality of webpages.
HTML Document Features
Responsive Design:HTML supports responsive web design through attributes like viewport in <meta> tags,
ensuring compatibility across devices.
Accessibility Features:HTML includes features like ARIA roles and attributes to make web content accessible to
users with disabilities.
Metadata Support:HTML allows inclusion of metadata through <meta> tags, improving search engine optimization
and document descriptions.
Cross-Platform Compatibility: HTML documents can be rendered across different browsers and operating systems,
ensuring universal access.
HTML command Tags
HTML command tags are used to define executable commands or interactive elements in an HTML document. These tags
provide functionality to users and developers for interactivity and advanced web features.
Key Command Tags:<button>:Defines a clickable button that can execute a JavaScript function, submit a form, or perform
other actions.Example: <button>Click Me</button>
<form>:Encapsulates input fields and controls for submitting user data to a server.Example: <form
action="/submit">...</form>
<input>:Used to create interactive controls for user input, such as text boxes, radio buttons, checkboxes, etc.Example: <input
type="text" name="username">
<select> and <option>:Create dropdown menus for selecting options.Example:htmlCopy code<select> <option
value="1">Option 1</option> <option value="2">Option 2</option></select>
<textarea>:Provides a multi-line input box for user text input.Example: <textarea rows="4" cols="50"></textarea>
<label>:Associates labels with form controls, improving accessibility.Example: <label for="email">Email:</label>These
command tags enhance the interactivity and functionality of HTML documents, allowing users to interact with the webpage
seamlessly.
Creating Links
Links in HTML are created using the <a> (anchor) tag, which is used to navigate between web pages, files, or
external resources.Syntax:htmlCopy code<a href="URL">Link Text</a>
href Attribute:Specifies the destination URL for the link.Example: <a href="https://example.com">Visit Example</a>
Open in New Tab:Use the target="_blank" attribute to open the link in a new browser tab.Example: <a
href="https://example.com" target="_blank">Open in New Tab</a>
Internal Links:Link to another page within the same website by providing a relative path.Example: <a
href="/about.html">About Us</a>
Anchor Links:Navigate to a specific section within the same page using an id attribute.Example:htmlCopy code<a
href="#section1">Go to Section 1</a><h2 id="section1">Section 1</h2>
Email Links:Use mailto: in the href to create an email link.Example: <a href="mailto:info@example.com">Email
Us</a>
Phone Links:Use tel: to create a clickable phone number.Example: <a href="tel:+123456789">Call Us</a>Links are
essential for navigation and connecting web content effectively.
Headers
Headers in HTML are used to define the titles and headings of a webpage, organizing content into a structured
hierarchy.Header Tags:HTML provides six levels of header tags, ranging from <h1> to <h6>.
<h1>:The highest-level heading, typically used for the main title of a webpage.Example: <h1>Main Title</h1>
<h2> to <h6>:Subheadings, each progressively smaller and used for organizing sections and
subsections.Example:htmlCopy code<h2>Section Title</h2><h3>Subsection Title</h3>
Semantic Structure:Headers provide semantic meaning, helping search engines and assistive technologies
understand the document's structure.
Styling:Headers can be styled with CSS for consistent appearance.Example:cssCopy codeh1 { font-size: 2em; color:
navy; }
SEO Optimization:Proper use of header tags improves SEO by signaling content hierarchy and relevance.
Nested Use:Headers are often used in a nested manner for clear organization, like in articles or reports.Headers are
crucial for readability, accessibility, and enhancing user experience on the web.
Text styles
HTML provides various tags to style and format text, enhancing readability and visual appeal.
Bold Text:<b>: Displays text in bold for emphasis (non-semantic).Example: <b>Bold Text</b><strong>: Displays text
in bold with semantic emphasis.Example: <strong>Important Text</strong>
Italic Text:<i>: Displays text in italics for styling (non-semantic).Example: <i>Italic Text</i><em>: Displays text in
italics with semantic emphasis.Example: <em>Highlighted Text</em>
Underlined Text:<u>: Underlines text, often for stylistic purposes.Example: <u>Underlined Text</u>
Strikethrough Text:<s>: Displays text with a strikethrough to indicate deletion or inaccuracy.Example: <s>Old
Price</s>
Subscript and Superscript:<sub>: Displays text as subscript.Example: H<sub>2</sub>O<sup>: Displays text as
superscript.Example: x<sup>2</sup>
Code and Monospace:<code>: Formats text as code with a monospace font.Example:
<code>console.log('Hello')</code>
Text Structuring
Text structuring in HTML involves organizing and formatting content to improve readability and semantic meaning.
HTML provides various tags for creating structured, well-organized text.
Paragraphs:<p>: Defines a block of text as a paragraph.Example: <p>This is a paragraph.</p>
Headings:<h1> to <h6>: Organize content into sections and subsections, with <h1> being the largest and <h6> the
smallest.Example: <h2>Subheading</h2>
Lists:Ordered List <ol>: Creates a numbered list.Example:htmlCopy code<ol> <li>First item</li> <li>Second
item</li></ol>
Unordered List <ul>: Creates a bulleted list.Example:htmlCopy code<ul> <li>First item</li> <li>Second
item</li></ul>
Definition List <dl>: Creates a list of terms and descriptions.Example:htmlCopy code<dl> <dt>HTML</dt>
<dd>HyperText Markup Language</dd></dl>
Line Breaks:<br>: Inserts a line break within text.Example: Line one<br>Line two
Text Structuring
Horizontal Rule:<hr>: Inserts a horizontal line to separate content sections.Example: <hr>
Blockquotes:<blockquote>: Displays a quoted section of text.Example: <blockquote>Quote goes
here.</blockquote>
Importance:
•Improves readability and accessibility.
•Enhances content organization and flow.
•Helps search engines understand document structure for better SEO.
Structured text ensures a logical, user-friendly presentation of information.
Text colors and Background
HTML allows customization of text colors and background styles using attributes or CSS for better aesthetics and
readability.
Using the style Attribute:The color property sets the text color.Example:htmlCopy code<p style="color: red;">This is
red text.</p>
CSS Classes or Inline Styles:Define colors using predefined names, hex codes, RGB, or HSL values.Example:htmlCopy
code<p style="color: #ff5733;">This is styled text.</p><p style="color: rgb(0, 128, 0);">This is green text.</p>
Background Colors:
Using the style Attribute:The background-color property sets the background color of an element.
Example:htmlCopy code<div style="background-color: yellow;">This has a yellow background.</div>
Text and Background Combination:Apply both text and background colors together for contrast.Example:htmlCopy
code<p style="color: white; background-color: black;">White text on a black background.</p>
Formatting text
HTML provides several tags to format text, enhancing its appearance and structure.
Bold and Strong:<b>: Makes text bold (non-semantic).Example: <b>Bold Text</b><strong>: Makes text bold with
semantic emphasis.Example: <strong>Important Text</strong>
Italic and Emphasis:<i>: Makes text italic (non-semantic).Example: <i>Italic Text</i><em>: Makes text italic with
semantic emphasis.Example: <em>Highlighted Text</em>
Underlining:<u>: Underlines text.Example: <u>Underlined Text</u>
Strikethrough:<s>: Displays text with a strikethrough.Example: <s>Incorrect Text</s>
Superscript and Subscript:<sup>: Formats text as superscript.Example: x<sup>2</sup><sub>: Formats text as
subscript.Example: H<sub>2</sub>O
Formatting text
Code and Monospace:<code>: Formats text as code in a monospace font.Example:
<code>console.log("Hello")</code><pre>: Preserves whitespace and formats text in a block with a monospace
font.Example:htmlCopy code<pre>Line 1Line 2</pre>
Highlighted Text:<mark>: Highlights text with a background color.Example: <mark>Important Note</mark>
Benefits:
•Improves readability and emphasis.
•Adds semantic meaning to text for accessibility and SEO.
•Enhances user engagement through visual distinction.
Page layouts
Page layout refers to the arrangement of elements on a webpage to ensure visual clarity and ease of navigation.
HTML, combined with CSS, is used to create structured and responsive layouts.
Using HTML Elements:Sections:Divide content using semantic tags like <header>, <nav>, <main>, <section>,
<article>, and <footer>.Example:htmlCopy code<header>Page Header</header><main>Content
Area</main><footer>Footer</footer>
Divisions:Use <div> to group content into blocks for layout purposes.Example:htmlCopy code<div
class="container">Content Block</div>
CSS for Layout:Flexbox:Arrange elements in a flexible and responsive layout.Example:cssCopy code.container {
display: flex; justify-content: center; align-items: center;}
Grid Layout:Create complex, two-dimensional layouts.Example:cssCopy code.container { display: grid;
grid-template-columns: 1fr 2fr;}
Page layouts
Positioning:Control element placement using relative, absolute, fixed, or sticky positioning.Example:cssCopy
code.box { position: absolute; top: 50px; left: 100px;}
Responsive Design:Use media queries to ensure layouts adjust to different screen sizes.Example:cssCopy
code@media (max-width: 600px) { .container { flex-direction: column; }}
Importance:
•Ensures a user-friendly interface.
•Enhances accessibility and navigation.
•Provides consistent design across different devices and screen sizes.