Wddnotes - Unit 1 HTML
Wddnotes - Unit 1 HTML
UNIT 1
Html
HTML (Hypertext Markup Language) is the standard markup language
for creating web pages. It describes the structure and content of a
webpage using a system of elements and tags. HTML allows developers
to organize text, embed images and videos, create links, and structure
the layout of a document. It works in conjunction with CSS for styling
and JavaScript for interactivity. HTML is the backbone of the World
Wide Web, interpreted by browsers to render visual representations of
web content.
Optimization
Prepare the site for optimal performance:
Minify CSS, JavaScript, and HTML
Optimize images and other media
Implement caching strategies
Use Content Delivery Networks (CDNs) for static assets
Uploading Files
Transfer your web files to the hosting server:
Use FTP (File Transfer Protocol) or SFTP (Secure File Transfer
Protocol)
Alternatively, use the hosting provider's file manager or Git integration
Configuring Server Settings
Set up the server environment:
Configure web server software (e.g., Apache, Nginx)
Set up SSL certificates for HTTPS
Configure any necessary server-side technologies (PHP, databases, etc.)
Final Testing
Perform a final round of testing on the live environment:
Check all pages and features
Verify proper loading of all assets
Test forms and server-side functionality
Ensure security measures are in place
Everything between the opening <p> tag and the closing </p> tag is
considered part of the paragraph.
Styling Paragraphs
While paragraphs have default styling, you can customize their
appearance using CSS:
html
p {
color: blue;
font-size: 16px;
line-height: 1.5;
}
Common Use Cases
Body Text: The main content of articles, blog posts, or informational
pages.
Descriptions: Product descriptions, bios, or explanatory text.
Quotes: When combined with the <blockquote> element for longer
quotations.
Best Practices
Semantic Usage: Use <p> tags for actual paragraphs, not for spacing or
layout purposes.
Readability: Keep paragraphs relatively short for better readability on the
web.
Consistency: Maintain consistent styling across paragraphs for a cohesive
look.
Accessibility: Ensure proper contrast between text and background colors.
Advanced Techniques
Drop Caps: Create stylized first letters using CSS:
css
p::first-letter {
font-size: 2em;
font-weight: bold;
}
css
.column-text {
column-count: 2;
column-gap: 40px;
}
css
p {
text-indent: 20px;
}
Common Mistakes to Avoid
Using <br> tags to create space between paragraphs instead of
proper <p> tags.
Nesting block-level elements (like <div>) inside paragraphs,
which is invalid HTML.
Using paragraphs for non-textual content or for layout purposes.
Implicit vs Explicit Tags in HTML
Explicit Tags
Explicit tags are HTML elements that are directly written in the
code by the developer. They have both opening and closing tags
(in most cases) and clearly define the structure and content of an
HTML document.
Characteristics:
Clearly visible in the HTML source code
Provide precise control over document structure
Most HTML elements are explicit
Examples:
html
<p>This is a paragraph.</p>
<div>This is a division.</div>
<h1>This is a heading.</h1>
Implicit Tags
Implicit tags are elements that are automatically inserted by the
browser's HTML parser, even when not explicitly written in the source
code. They are assumed to be present based on the document's structure
or the HTML specification.
Characteristics:
Not visible in the source code
Inserted by the browser to ensure proper document structure
Limited to a few specific cases in HTML
Examples:
<html>: If omitted, the browser will implicitly create it.
<head>: If missing, it's implicitly created before the <body>.
<body>: If absent, the browser assumes its presence.
<tbody>: Automatically inserted in tables if not explicitly defined.
Key Differences
Visibility:
Explicit tags are visible in the source code.
Implicit tags are not present in the source but are added by the browser.
Control:
Explicit tags offer direct control over document structure.
Implicit tags are based on browser behavior and HTML specifications.
Flexibility:
Explicit tags allow for more flexible and precise document structuring.
Implicit tags are limited to specific elements and scenarios.
Performance:
Explicit tags might slightly increase file size but ensure clarity.
Implicit tags can reduce file size but may lead to less clear code.
Compatibility:
Explicit tags ensure consistent behavior across different browsers.
Reliance on implicit tags may occasionally lead to rendering differences.
Best Practices
Use explicit tags for clear, maintainable code.
Understand where implicit tags are used to avoid confusion.
Don't rely on implicit tags for critical document structure.
Be aware of implicit tags when debugging layout issues.
Introduction
HTML (Hypertext Markup Language) uses a system of tags to define
the structure and content of web pages. Most HTML elements consist of
an opening tag and a closing tag, which together enclose the content
they affect. Understanding how these tags work is fundamental to
writing correct HTML.
Basic Structure
An HTML element typically follows this structure:
<tagname>Content goes here</tagname>
<tagname> is the opening tag
</tagname> is the closing tag
The content is placed between these tags
Types of Tags
Paired Tags: Most HTML elements use paired tags. Example: <p>,
</p> for paragraphs
Self-closing Tags: Some elements don't need a closing tag. Example:
<img>, <br>,
<input>
Nesting Tags
HTML elements can be nested inside each other. When nesting, it's
crucial to close tags in the reverse order they were opened.
Correct Nesting:
html
<div>
<p>This is <strong>correct</strong> nesting.</p>
</div>
Incorrect Nesting:
html
<div>
<p>This is <strong>incorrect nesting.</p>
</div></strong>
Importance of Proper Tag Usage
Structure: Defines the hierarchical structure of the document.
Semantics: Provides meaning to the content for browsers and search
engines.
Styling: Allows for precise CSS styling.
Functionality: Enables proper JavaScript interaction.
Accessibility: Ensures screen readers can interpret the content correctly.
Document Structure
<!DOCTYPE html>: Declares the document type and HTML version.
<html>: The root element of an HTML page.
<head>: Contains meta information about the document.
<body>: Defines the document's body, which contains all the visible
contents.
Metadata
<title>: Specifies a title for the HTML page (shown in browser's title
bar or page's tab).
<meta>: Specifies metadata about an HTML document.
<link>: Defines the relationship between a document and an external
resource.
<style>: Used to write inline CSS.
<script>: Used to embed a client-side script (JavaScript).
Text Content
<h1> to <h6>: Defines HTML headings.
<p>: Defines a paragraph.
<br>: Produces a line break in text (carriage-return).
<hr>: Represents a thematic break between paragraph-level elements.
<pre>: Defines preformatted text.
<blockquote>: Specifies a section that is quoted from another
source.
Inline Text Semantics
<a>: Defines a hyperlink.
<strong>: Defines important text.
<em>: Defines emphasized text.
<span>: Used to group inline-elements in a document.
<code>: Defines a piece of computer code.
<sub>: Defines subscripted text.
<sup>: Defines superscripted text.
<i>: Defines a part of text in an alternate voice or mood.
<b>: Specifies bold text without extra importance.
<mark>: Defines marked/highlighted text.
Lists
<ul>: Defines an unordered list.
<ol>: Defines an ordered list.
<li>: Defines a list item.
<dl>: Defines a description list.
<dt>: Defines a term/name in a description list.
<dd>: Defines a description of a term/name in a description list.
Table Content
<table>: Defines a table.
<tr>: Defines a row in a table.
<th>: Defines a header cell in a table.
<td>: Defines a cell in a table.
<caption>: Defines a table caption.
<thead>: Groups the header content in a table.
<tbody>: Groups the body content in a table.
<tfoot>: Groups the footer content in a table.
Forms and Input
<form>: Defines an HTML form for user input.
<input>: Defines an input control.
<textarea>: Defines a multiline input control (text area).
<button>: Defines a clickable button.
<select>: Defines a drop-down list.
<option>: Defines an option in a drop-down list.
<label>: Defines a label for an <input> element.
<fieldset>: Groups related elements in a form.
<legend>: Defines a caption for a <fieldset> element.
Semantic Sectioning Elements
<article>: Defines an article.
<section>: Defines a section in a document.
<nav>: Defines navigation links.
<aside>: Defines content aside from the page content.
<header>: Specifies a header for a document or section.
<footer>: Specifies a footer for a document or section.
<main>: Specifies the main content of a document.
Interactive Elements
<details>: Defines additional details that the user can view or hide.
<summary>: Defines a visible heading for a <details> element.
<dialog>: Defines a dialog box or window.
Embedded Content
<iframe>: Defines an inline frame.
<embed>: Defines a container for an external application.
<object>: Defines an embedded object.
<param>: Defines a parameter for an object.
<h2>Conclusion</h2>
<p>This section summarizes the key points of the article and provides
some
SRC Attribute (Source)
Purpose: Primarily used to specify the source of external
content.
Common use cases:
o Images: <img src="image.jpg">
o Audio: <audio src="music.mp3">
o Video: <video src="video.mp4">
o Scripts: <script src="script.js"></script>
Functionality: The src attribute tells the browser to load the
specified resource and embed it into the current HTML document.
Key points:
o The value of the src attribute should be a URL that points to
the location of the resource.
o If the resource is located on the same server as the HTML
document, you can use a relative URL.
o If the resource is located on a different server, you must use
an absolute URL.
o The browser will load the resource asynchronously, meaning
that the rest of the page will continue to load while the
resource is being fetched.
HREF Attribute (Hypertext Reference)
Purpose: Creates a link to another resource.
Common use cases:
o Anchors within a page: <a href="#section2">Go to Section
2</a>
o Links to external pages: <a
href="https://example.com">Visit Example</com>
o Download links: <a href="file.pdf" download>Download
PDF</a>
Functionality: The href attribute tells the browser to navigate to
the specified resource when the link is clicked.
Key points:
o The value of the href attribute should be a URL that points
to the location of the resource.
o If the resource is located on the same server as the HTML
document, you can use a relative URL.
o If the resource is located on a different server, you must use
an absolute URL.
o The browser will load the linked resource in a new tab or
window by default, but you can change this behavior using
the target attribute.
Image Tag (IMG)
Purpose:
Used to insert images into an HTML document.
Syntax:
HTML
<img src="image_url" alt="alternative text">
Attributes:
src: Specifies the URL of the image.
alt: Provides an alternative text description for the image, which is
used by screen readers and when the image cannot be loaded.
width: Sets the width of the image in pixels.
height: Sets the height of the image in pixels.
title: Provides a tooltip that appears when the user hovers over the
image.
style: Allows you to apply CSS styles to the image.
Best Practices:
Use descriptive alt text that accurately describes the content of the
image.
Optimize image files for web use by compressing them without
sacrificing quality.
Consider using a responsive image technique like srcset and sizes
to provide different image sizes for different screen resolutions.
Avoid using images as background elements, as they can impact
page load times.
Use images sparingly and only when they add value to the content.