You are on page 1of 11

LINKS…

In HTML, links and hyperlinks are fundamental elements used to navigate between different web
pages or resources. Here's an explanation of links and hyperlinks in HTML:
Definition:
Links and hyperlinks are elements in HTML used to connect one web page to another or to different
sections within the same page. They enable users to navigate through websites and access various
resources such as documents, images, videos, or other web pages.
Syntax:
In HTML, links are created using the <a> (anchor) element, which stands for "anchor." The <a>
element is paired with an opening <a> tag and a closing </a> tag. The href attribute within the
opening tag specifies the destination URL or the location of the resource being linked to.
Example:
<a href="https://www.example.com">Visit Example Website</a>
Text Content:
The text between the opening and closing <a> tags serves as the clickable text for the link. This is
what users see on the webpage and click on to navigate to the linked resource.

Absolute vs. Relative URLs:


The href attribute can contain either an absolute URL (starting with "http://" or "https://") or a
relative URL (specifying the path relative to the current webpage). Absolute URLs point to a specific
location on the web, while relative URLs point to resources within the same website or directory
structure.

Example of an absolute URL:


<a href="https://www.example.com/page2.html">Go to Page 2</a>
Example of a relative URL:
<a href="page2.html">Go to Page 2</a>

Hyperlinks:
Hyperlinks are active links that users can click on to navigate to the linked resource. When a user
clicks on a hyperlink, the browser redirects them to the URL specified in the href attribute of the <a>
element.

Hyperlinks can also be styled using CSS to change their appearance (such as color, underline, etc.) to
make them stand out and indicate to users that they are clickable.
FORM…
Form tags in HTML are used to create a structured way of collecting user input on a web page. They
allow users to enter data, such as text, numbers, selections, and submit it to a server for processing.

Opening and Closing Tags:


The form tags are represented by the <form> opening tag and the </form> closing tag. All form
elements are placed within these tags, defining the boundaries of the form on the webpage.

Action Attribute:
The action attribute in the <form> tag specifies the URL or file where the form data will be
submitted for processing. For example, action="process.php" would send the form data to a PHP
script named process.php on the server.

Method Attribute:
The method attribute in the <form> tag specifies the HTTP method used to send the form data to the
server. The two common methods are GET and POST. With GET, the form data is appended to the
URL as query parameters, while with POST, the data is sent in the body of the HTTP request. For
example, method="post".

Form Controls:
Within the <form> tags, various form controls can be used to collect user input. These controls
include input fields (<input>), text areas (<textarea>), select dropdowns (<select>), checkboxes
(<input type="checkbox">), radio buttons (<input type="radio">), and buttons (<button>).

Submit Button:
A common form control is the submit button (<input type="submit"> or <button type="submit">).
When clicked, this button submits the form data to the server for processing.

Overall, form tags provide a structured way to collect user input and submit it to a server for further
processing, making them an essential part of interactive web applications. Understanding how to use
form tags and their attributes is crucial for building dynamic and user-friendly web pages.

/////
Text Input: This is a box where users can type text, like their name or email address. It's created using
the <input> tag with the type="text" attribute.
Text Area: Similar to a text input, but for longer messages or paragraphs. It's created using the
<textarea> tag.

Dropdown Menu: This is a list of options where users can select one. It's created using the <select>
tag, with each option listed inside it.

Checkboxes: These are small boxes that users can tick or untick. They're used when there are multiple
options, and users can choose more than one. Created with the <input> tag and type="checkbox".

Radio Buttons: Similar to checkboxes, but users can only select one option. If they choose one, it
automatically deselects any others. Created with the <input> tag and type="radio".
//////

FORM CODE …
EXAMPLE FORM :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example Form</title>
</head>
<body>

<h2>Example Form</h2>

<form action="process.php" method="post">


<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>

<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="message">Message:</label><br>
<textarea id="message" name="message" rows="4" cols="50" required></textarea><br><br>

<label for="gender">Gender:</label><br>
<input type="radio" id="male" name="gender" value="male" required>
<label for="male">Male</label><br>
<input type="radio" id="female" name="gender" value="female" required>
<label for="female">Female</label><br><br>

<label for="age">Age:</label>
<select id="age" name="age" required>
<option value="">Select...</option>
<option value="under18">Under 18</option>
<option value="18to30">18 - 30</option>
<option value="31to50">31 - 50</option>
<option value="over50">Over 50</option>
</select><br><br>

<input type="checkbox" id="subscribe" name="subscribe" value="yes">


<label for="subscribe">Subscribe to newsletter</label><br><br>

<input type="submit" value="Submit">


</form>

</body>
</html>

TABLE …
In HTML, a table is a way to organize data in rows and columns. It's like a grid where you can place
information neatly.
The <table> tag is used to create a table in HTML. Inside the <table> tag, you can use other tags
like <tr> for rows, <td> for data cells, and <th> for header cells.

More :
<table>: This tag marks the beginning and end of the table. Everything inside this tag is part of the
table.
<tr>: Stands for "table row." Each <tr> tag defines a new row in the table. Inside each <tr>, you
can have <td> or <th> tags.
<td>: Stands for "table data." It represents a single cell of data within a row. You place the actual
content (text, images, etc.) inside <td> tags.
<th>: Stands for "table header." Similar to <td>, but it's used for headers (like column titles) rather
than regular data. Text inside <th> tags is usually bold and centered by default.

EXAMPLE CODE TABLE :

<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td> Sani</td>
<td>20</td>
</tr>
<tr>
<td>Emily</td>
<td>19</td>
</tr>
</table>

CSS AND ITS TYPES…


CSS (Cascading Style Sheets):
CSS is a language used for describing the presentation of a document written in a markup language
like HTML. It controls how HTML elements are displayed on a webpage, including things like layout,
colors, fonts, and spacing.

Types of CSS:
1. INLINE CSS : Inline CSS is applied directly to an HTML element using the style attribute.

EXAMPLE INLINE CSS :


<p style="color: blue; font-size: 16px;">This is a paragraph with inline CSS.</p>

Inline CSS affects only the specific element it's applied to and overrides any external or internal CSS.

2. INTERNAL CSS : Internal CSS is defined within the HTML document using the <style> tag in the
<head> section.

EXAMPLE INTERNAL CSS :


<head>
<style>
p{
color: red;
font-size: 18px;
}
</style>
</head>
<body>
<p>This is a paragraph with internal CSS.</p>
</body>
Internal CSS applies styles to all elements specified within the <style> tag.

3. EXTERNAL CSS : External CSS is defined in a separate file with a .css extension and linked to the
HTML document using the <link> tag in the <head> section.
EXAMPLE EXTERNAL CSS :
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>

The href attribute specifies the path to the external CSS file. External CSS allows you to apply styles
across multiple HTML documents, promoting consistency and easier maintenance.

IMAGE…
In HTML, images are used to display visual content on a webpage. They can be photos, illustrations,
icons, or any other type of visual element.

To include an image in an HTML document, you use the <img> tag. This tag is self-closing, meaning
it doesn't have a closing tag. Instead, it includes attributes that specify important details about the
image, such as its source (the URL of the image file), its dimensions (width and height), and
alternative text (for accessibility purposes).

Here's an example of how you would use the <img> tag to display an image :

<img src="image.jpg" alt="Description of the image" width="200" height="150">

In this example:

- 'src' specifies the URL or path to the image file.


- 'alt' provides alternative text that describes the image, which is important for accessibility and for
situations where the image cannot be displayed.
- 'width' and 'height' specify the dimensions of the image. These attributes are optional, but they can
be used to control the size of the image displayed on the webpage.
SEMANTIC ELEMENTS AND TAGS
Semantic elements and semantic tags in HTML are important concepts that refer to the use of specific
HTML elements to give meaning and structure to web content.

Semantic Elements :
Semantic elements are HTML elements that carry meaning beyond just their appearance or
formatting. They provide context and convey the purpose or function of the content they enclose.
Using semantic elements helps both humans and search engines better understand the structure and
meaning of a web page.

Semantic Tags :
Semantic tags are specific HTML elements that are designed to represent different types of content on
a web page in a meaningful way. These tags are chosen based on the type of content being
represented, such as headings, paragraphs, lists, navigation menus, and more.

Here are some examples of semantic tags and their purposes:

<header>: Represents introductory content at the top of a page or section.


<nav>: Represents a navigation menu.
<main>: Represents the main content of a page.
<article>: Represents a self-contained piece of content, such as a blog post or article.
<section>: Represents a thematic grouping of content within a document.
<aside>: Represents content that is tangentially related to the main content.
<footer>: Represents the footer of a page or section, typically containing copyright information,
contact details, etc.

By using semantic elements and tags appropriately, web developers can create well-structured and
accessible web pages that are easier to understand and navigate for both users and search engines.
This can lead to improved user experience, better search engine rankings, and overall higher-quality
websites.
EXAMPLE CODE :

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Semantic ka Example</title>
</head>
<body>
<header>
<h1>Swagat to My Website</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>

<main>
<article>
<h2>Article Title</h2>
<p>This is the content of the article...</p>
</article>

<section>
<h2>Section Title</h2>
<p>This is some content within a section...</p>
</section>
<aside>
<h2>Related Links</h2>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</aside>
</main>

<footer>
<p>&copy; 2024 My Website. All rights reserved.</p>
</footer>
</body>
</html>

In this code:

<header>, <nav>, <main>, <article>, <section>, <aside>, and <footer> are semantic elements.
They provide meaning and structure to different parts of the webpage.
Within these elements, we use appropriate tags like <h1>, <h2>, <p>, <ul>, and <li> to further
organize and present content.
This code creates a basic webpage layout with a header, navigation menu, main content area, sidebar,
and footer, all using semantic HTML elements and tags.

You might also like