[go: up one dir, main page]

0% found this document useful (0 votes)
1 views2 pages

Lecture 4

Uploaded by

0112cs221035
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

Lecture 4

Uploaded by

0112cs221035
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

LECTURE-4

Forms in HTML
Sure! The `<form>` tag in HTML is used to create an HTML form for user input. It's a container
for form elements, such as input fields, buttons, checkboxes, radio buttons, and more.

Here's the basic structure of a `<form>` tag:

```html

<form action="URL_where_form_data_will_be_sent" method="HTTP_method">

<!-- Form elements go here -->

</form>

```

Let's break down the attributes:

- `action`: This attribute specifies the URL (web address) where the form data will be submitted
when the form is submitted. It can be a relative or absolute URL.

- `method`: This attribute specifies the HTTP method to be used when submitting the form data.
The two most common methods are:

- `GET`: The form data is appended to the URL in the form of query parameters. It's suitable for
forms with a small amount of data and when you want users to be able to bookmark or share
the resulting URL.

- `POST`: The form data is sent in the body of the HTTP request. It's suitable for forms with
sensitive data or large amounts of data.

Here's an example of a simple form:

```html
<form action="/submit-form" method="POST">

<label for="username">Username:</label>

<input type="text" id="username" name="username"><br><br>

<label for="password">Password:</label>

<input type="password" id="password" name="password"><br><br>

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

</form>

```

In this example:

- The form will be submitted to `/submit-form` when the user clicks the submit button.

- Two input fields are included: one for the username and one for the password.

- Each input field has a `name` attribute, which is used to identify the data when the form is
submitted.

- The submit button (`<input type="submit">`) is used to send the form data to the server.

When the user fills out this form and clicks the submit button, the data will be sent to the
server according to the specified action and method.

You might also like