css-10,11
css-10,11
Objectives:
Outcomes:
Theoretical Explanation
HTMLForm
An HTML form is used to collect user input. The user input is most often sent to a
server for processing.
The <form> element is a container for different types of input elements, such
as: text fields, checkboxes, radio buttons, submit buttons, etc.
Text Fields
The <input type="text"> defines a single-line input field for text input.
The <label> element in HTML is used to define a label for a form control. It improves accessibility
by associating the label with a form element, such as an input or checkbox, and helps screen readers
announce the label. The for attribute links the label to a form control by matching its id. Clicking
the label activates the corresponding input field.
Radio Buttons
The <input type="radio"> defines a radio button.
Checkboxes
The <input type="checkbox"> defines a checkbox.
The form-handler is typically a file on the server with a script for processing
input data.
action="/submit-form": Specifies that the form data will be sent to the /submit-form
URL when the form is submitted.
method="POST": Specifies that the form data will be sent using the POST method (you
can also use GET if needed).
The rows attribute specifies the visible number of lines in a text area.
<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">
Some smartphones recognize the email type, and add ".com" to the keyboard
to match email input.
Demo Form
If the name attribute is omitted, the value of the input field will not be sent at
all.
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
When tags like <font>, and color attributes were added to the HTML 3.2
specification, it started a nightmare for web developers. Development of
large websites, where fonts and color information were added to every single
page, became a long and expensive process.
To solve this problem, the World Wide Web Consortium (W3C) created CSS.
With an external stylesheet file, you can change the look of an entire website
by changing just one file!
Using CSS
CSS can be added to HTML documents in 3 ways:
Inline CSS
An inline CSS is used to apply a unique style to a single HTML element.
The following example sets the text color of the <h1> element to blue, and
the text color of the <p> element to red:
Internal CSS
An internal CSS is used to define a style for a single HTML page.
The following example sets the text color of ALL the <h1> elements (on that
page) to blue, and the text color of ALL the <p> elements to red. In addition,
the page will be displayed with a "powderblue" background color:
External CSS
An external style sheet is used to define the style for many HTML pages.
To use an external style sheet, add a link to it in the <head> section of each
HTML page:
The external style sheet can be written in any text editor. The file must not
contain any HTML code, and must be saved with a .css extension.
CSS Syntax
A CSS rule consists of a selector and a declaration block.
In lab Task:
Lab Task: