Webdev
Webdev
26-July-24
WebDev
Maasma Zari
HTML Basics
Web Development Basics
HTML (HyperText Markup Language)
HTML is the fundamental language used to structure and format web
pages. It defines the layout and content of a webpage through elements
known as tags.
HTML Tags
HTML tags are the building blocks of web pages, defining the structure
and content.Tags are containers used to enclose content or other tags.
HTML Element: The root element that contains all other elements.
Body Element: Contains the main content that is displayed on the page.
<body> <!-- Visible content goes here --> </body>
Self-Closing Tags: Some tags are self-closing, e.g., <br> for line breaks.
Comments: Written as <!-- Comment --> and are not displayed on the
page.
Heading Tags: <h1> to <h6>, with <h1> being the most important.
REPORT TITLE 2
Heading tags in HTML (<h1> to <h6>) are used to define headings and
subheadings on a web page. They create a hierarchy of importance and
structure for content:
Basic Structure
<a href="URL" target="value">Link Text</a>
REPORT TITLE 3
<a href="URL of any page " target="_self">Visit Example (Self)</a>
oUse Case: Useful for navigating within the same context or
page.
2. _parent
o Description: Opens the linked document in the parent frame, if
REPORT TITLE 4
alt (Alternative Text): Provides a textual description of the image
for accessibility and SEO. Displayed if the image cannot load.
Example Usage:
<img src="/path/to/image.jpg" alt="Description of the image">
Additional Attributes:
width and height: Define the dimensions of the image in pixels.
title: Provides additional information, displayed as a tooltip on hover.
Bold: <b>Bold</b>.
Italic: <i>Italic</i>.
Underline: <u>Underline</u>.
Big & Small Text: <big>Big</big>, <small>Small</small>.
REPORT TITLE 5
<main> Tag
Encapsulates the main content of the document, excluding headers,
footers, and sidebars.
Usage:
<main>
<h2>Main Content</h2>
<p>This is the primary content area of the page.</p>
</main>
<footer> Tag
Defines the footer for a page or section, typically containing contact
information, copyright, or additional links.
Usage:
<footer>
<p>© 2024 My Website. All rights reserved.</p>
<a href="#contact">Contact Us</a>
</footer>
REPORT TITLE 6
Example Usage:
<section>
<h2>Section Title</h2>
<p>Content related to the section.</p>
</section>
<article> Tag: Standalone Content
The <aside> tag is used for content that is tangentially related to the main
content, such as sidebars, pull quotes, or advertisements. It often provides
supplementary information.
Key Points:
Purpose: To include content aside from the main content, often used
for secondary information.
Usage: Ideal for sidebars, additional information, or ads.
REPORT TITLE 7
Example Usage:
<aside>
<h2>Related Information</h2>
<p>Additional content like advertisements or related links.</p>
</aside>
Anchor Tag with Images
The <a> (anchor) tag can be used with the <img> tag to make images
clickable, linking to other pages or resources.
Key Points:
Purpose: To create clickable images that function as hyperlinks.
Usage: Wrap the <img> tag with an <a> tag to turn the image into a
clickable link.
Example Usage:
<a href="https://example.com">
<img src="/path/to/image.jpg" alt="Clickable Image">
</a>
Attributes:
href: Specifies the URL to navigate to when the image is clicked.
alt: Provides alternative text for the image.
REPORT TITLE 8
Usage: Typically used for grouping content and applying styles or
scripts.
Example Usage:
<div class="container">
<h2>Section Title</h2>
<p>Content goes here.</p>
</div>
Best Practices:
Use <div> for logical grouping of content and layout sections.
Combine with CSS classes or IDs to style or target specific sections.
REPORT TITLE 9
Unordered List (<ul>)
The <ul> tag creates an unordered (bulleted) list. It is used to group items
that do not require a specific order.
Structure:
<ul>: The container for the list.
<li>: List item, used within the <ul> container.
Example Usage:
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
Best Practices:
Use <ul> for lists where the order of items is not important.
Ensure each item is enclosed in an <li> tag for proper formatting.
REPORT TITLE 11
<tbody> Tag: Table Body
Purpose: Contains the main content of the table, consisting of data
rows.
Placement: Follows the <thead> and precedes the <tfoot> (if
present).
Example Usage:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
<tr>
<td>Data 3</td>
<td>Data 4</td>
</tr>
</tbody>
</table>
Best Practices:
Use <tbody> to group the main data rows of the table.
Ensures separation of headers, body, and footers for better table
organization and styling.
REPORT TITLE 12
Forms in HTML
Forms are used to collect user input and submit data to a server. They are a
fundamental part of interactive web applications.
Basic Structure:
The <form> tag defines the start and end of a form. It contains various
input elements and attributes to specify how data is submitted.
<form action="/submit" method="post">
<!-- Form elements here -->
</form>
action: Specifies the URL where the form data will be sent.
method: Specifies the HTTP method (e.g., post, get) to use when
sending form data.
Input Elements:
The <input> tag is used for various types of user inputs. The type attribute
determines the kind of input field.
<input type="text" placeholder="Enter Name">
type="text": Creates a single-line text input field.
placeholder: Provides a hint to the user about what to enter.
Labels:
The <label> tag is used to define labels for form elements, improving
accessibility and usability.
<label for="name">Name:</label>
<input type="text" id="name" placeholder="Enter Name">
for: Associates the label with a specific form element by id.
REPORT TITLE 13
Checkboxes:
The <input> tag with type="checkbox" creates a checkbox input.
<input type="checkbox" id="subscribe" name="subscribe" value="yes">
<label for="subscribe">Subscribe to newsletter</label>
type="checkbox": Creates a checkbox.
name: Identifies the checkbox in form submission.
Textareas:
The <textarea> tag is used for multi-line text input.
<textarea rows="4" cols="50" placeholder="Enter your
message"></textarea>
rows: Specifies the number of visible text lines.
cols: Specifies the width of the text area.
Multimedia Elements
Multimedia elements include embedded videos and other media types,
enhancing the content on web pages.
Iframe:
The <iframe> tag embeds another HTML page within the current page.
<iframe src="https://example.com" width="600" height="400"></iframe>
src: Specifies the URL of the page to embed.
width and height: Define the dimensions of the iframe.
Video:
The <video> tag is used to embed video content on a webpage.
REPORT TITLE 14
<video src=" https://archive.org/details/Sample-Video-Mp4" controls>My
Video</video>
src: Specifies the path to the video file.
controls: Adds video controls like play, pause, and volume.
Fallback Content: Text inside the <video> tag is displayed if the
browser does not support the video element.
REPORT TITLE 15