Lab Manual 03
Lab Manual 03
Contents:
• Intro to Web Engineering
• Technologies
• Tools
• HTML Tags basic and advanced
• Intro to CSS
Technologies to be studied
• HTML
• CSS
• JavaScript
• Bootstrap
• JQuery
• PHP
• MySQL [Database]
• Laravel [PHP FRAMEWORK]
Tools – IDEs
• Visual Studio Code
• Adobe Dreamweaver
• Visual Studio
3.1 The <form> Element
The HTML <form> element is used to create an HTML form for user input:
<form>
form elements
</form>
The <form> element is a container for different types of input elements, such as:
text fields, checkboxes, radio buttons, submit buttons, etc. All the different form
elements are covered in this chapter: HTML Form Elements.
The <input> Element. The HTML <input> element is the most used form element.
An <input> element can be displayed in many ways, depending on the type
attribute.
• <input>
• <label>
• <select>
• <textarea>
• <button>
• <fieldset>
• <legend>
• <datalist>
• <output>
• <option>
• <optgroup>
Radio Buttons
The <input type="radio"> defines a radio button.
Radio buttons let a user select ONE of a limited number of choices.
<!DOCTYPE html>
<html>
<body>
<h2>Radio Buttons</h2>
<form>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
</body>
</html>
Checkboxes
The <input type="checkbox"> defines a checkbox.
</form>
</body>
</html>
The form-data can be sent as URL variables (with method="get") or as HTTP post
transaction (with method="post").
The default HTTP method when submitting form data is GET.
Notes on GET:
Notes on POST:
• Appends the form data inside the body of the HTTP request (the
submitted form data is not shown in the URL)
• POST has no size limitations, and can be used to send large amounts of
data.
• Form submissions with POST cannot be bookmarked
Note: The size attribute works with the following input types: text, search, tel, url,
email, and password.
Note: When a maxlength is set, the input field will not accept more than the
specified number of characters. However, this attribute does not provide any
feedback. So, if you want to alert the user, you must write JavaScript code.
Tip: Use the max and min attributes together to create a range of legal values.
Tip: Use the global title attribute to describe the pattern to help the user.
<form>
<label for="country_code">Country code:</label>
<input type="text" id="country_code" name="country_code"
pattern="[A-Za-z]{3}" title="Three letter country code">
</form>
<form>
<label for="phone">Enter a phone number:</label>
<input type="tel" id="phone" name="phone"
placeholder="123-45-678"
pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}">
</form>
The required Attribute
The input required attribute specifies that an input field must be filled out before
submitting the form.
The required attribute works with the following input types: text, search, url, tel,
email, password, date pickers, number, checkbox, radio, and file.
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
</form>
The overflow property specifies whether to clip the content or to add scrollbars
when the content of an element is too big to fit in the specified area.
• visible - Default. The overflow is not clipped. The content renders outside
the element's box
• hidden - The overflow is clipped, and the rest of the content will be invisible
• scroll - The overflow is clipped, and a scrollbar is added to see the rest of
the content
• auto - Similar to scroll, but it adds scrollbars only when necessary
div {
width: 200px;
height: 65px;
background-color: coral;
overflow: visible;
}
CSS z-index Property
The z-index property specifies the stack order of an element. An element with
greater stack order is always in front of an element with a lower stack order.
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
• static
• relative
• fixed
• absolute
• sticky
Elements are then positioned using the top, bottom, left, and right properties.
However, these properties will not work unless the position property is set first.
They also work differently depending on the position value.
Static
HTML elements are positioned static by default.
Static positioned elements are not affected by the top, bottom, left, and right
properties.
Relative:
Fixed
An element with position: fixed; is positioned relative to the viewport, which
means it always stays in the same place even if the page is scrolled. The top,
right, bottom, and left properties are used to position the element.
Absolute:
An element with position: absolute; is positioned relative to the nearest positioned
ancestor (instead of positioned relative to the viewport, like fixed):
Sticky:
An element with position: sticky; is positioned based on the user's scroll
position.
CSS Opacity / Transparency
The opacity property specifies the opacity/transparency of an element.
The opacity property can take a value from 0.0 - 1.0. The lower the value, the
more transparent:
img {
opacity: 0.5;
}
Combinatory:
A combinator is something that explains the relationship between the selectors.
A CSS selector can contain more than one simple selector. Between the simple
selectors, we can include a combinator.
Descendant Selector
div p {
background-color: yellow;
}
Child Selector (>)
The child selector selects all elements that are the children of a specified
element. The following example selects all <p> elements that are children of a
<div> element:
div > p {
background-color: yellow;
}
The adjacent sibling selector is used to select an element that is directly after
another specific element. Sibling elements must have the same parent element,
and "adjacent" means "immediately following". The following example selects
the first <p> element that are placed immediately after <div> elements:
div + p {
background-color: yellow;
}
The general sibling selector selects all elements that are next siblings of a
specified element. The following example selects all <p> elements that are next
siblings of <div> elements:
div ~ p {
background-color: yellow;
}
Lab Task
Task-1
Create a Web Form in which all types of INPUT TYPE used [which we learn in this lab] using CSS to make
it interactive.
Task-2
Create a dropdown as like below; in which USA and Canada cannot be selected.
Task-3
Create a Web Form in which Sign-in AND Sign-up shown as like below.
Task-4
Create a Web Form in which Contact US shown using the placeholder as like below.
Task-5
Create a Header with NavBar using all types of Combinatory which you learn in this Lab.
Task-6
Task-7
Using position [all properties] places all text on the image according to the position right top, left top,
bottom left, bottom right and on center, where image used opacity to look light.
Task-8
Using CSS properties create the below box in which margin, padding, outlines and content will be used.