forms explanation html
forms explanation html
1. <!DOCTYPE html>: Declares the document type and version of HTML being used
(HTML5 in this
case).
2. <html
lang="en">: The
root element that
wraps all the
content. The lang
attribute specifies
the language of
the document
(English in this
case).
3. <head>: Contains
meta-information
about the HTML
document, such as
the title, character
set, and links to
stylesheets.
4. <meta
charset="UTF-
8">: Specifies the character encoding for the HTML document (UTF-8).
5. <meta name="viewport" content="width=device-width, initial-scale=1.0">:
Sets the viewport properties for responsive web design, ensuring the page scales well
on different devices.
6. <title>Registration Form</title>: Sets the title of the web page, which is
displayed in the browser's title bar or tab.
7. <link rel="stylesheet" href="styles.css">: Links the external CSS file
(styles.css) to the HTML document, allowing the styles defined in the CSS file to
be applied.
8. <body>: Contains the main content of the HTML document.
9. <div class="container">: Creates a division or section of content. The
class="container" attribute assigns a class name that can be used to apply CSS
styles.
10. <h2>Registration Form</h2>: Defines a level 2 heading with the text "Registration
Form".
11. <form action="#" method="post">: Creates a form for user input. The action="#"
attribute specifies the URL where the form data will be sent (currently a
placeholder), and the method="post" attribute specifies that form data should be
sent using the POST method.
12. <label for="username">Username:</label>: Defines a label for the username
input field. The for="username" attribute associates the label with the input field
that has the ID "username".
13. <input type="text" id="username" name="username" required>: Defines an
input field for text. The type="text" attribute specifies that this is a text input field,
the id="username" attribute assigns an ID to the field, the name="username"
attribute provides a name for the field, and the required attribute indicates that
this field must be filled out before submitting the form.
14. <input type="email" id="email" name="email" required>: Defines an input
field for email. The type="email" attribute specifies that this is an email input field.
15. <input type="password" id="password" name="password" required>: Defines
an input field for the password. The type="password" attribute specifies that this is
a password input field.
16. <input type="password" id="confirm-password" name="confirm-password"
required>: Defines an input field for confirming the password. The id="confirm-
password" attribute assigns an ID to the field.
17. <button type="submit">Register</button>: Defines a button that submits the
form when clicked. The type="submit" attribute specifies that this is a submit
button.
CSS Code Functions: