Task 4 - Styling Forms

Updated on: Mar. 4, 2024

This is Lab Task to practice basic CSS properties.

Save below code in form.html file and define CSS styles in head section such that the form shall look as per attached image i.e. form.png. Do not use 'br' tag for spacing but use margins etc. Try to keep the code size minumum to create required user interface (UI), so use selectors most effectively to achieve this target. Style guideline image is also attached i.e. form-help.png, please use it to decide what CSS properties shall be applied on which elements.

<!doctype html>


  /* define all styles here */ 


<div id="container">
 <h1> Student Registration Form </h1>
 <form method="GET" action="register.jsp">
  <div class="userinput">
   <label> First Name  </label> 
   <input type="text" name="firstName" value="" /> 
  <div class="userinput">
   <label> Last Name  </label> 
   <input type="text" name="lastName" value="" />
  <div class="userinput">
   <label> Email </label>   
   <input type="text" name="email" value="" />
  <div class="userinput">
   <label> Gender </label>
   <input type="radio" name="gender" value="m"/> Male
   <input type="radio" name="gender" value="f" /> Female    
  <div class="userinput">
   <label> Choose Subjects </label>    
   <input type="checkbox" name="subject" value="OOP"/> OOP 
   <input type="checkbox" name="subject" value="DB" checked/> Database 
   <input type="checkbox" name="subject" value="Web"/> Web Technologies 
   <input type="checkbox" name="subject" value="Android"/> Android Dev. 
  <div class="userinput">
   <label>Comments </label>
   <textarea name="comments" rows="7" cols="40">Description comes here...</textarea> 
  <div class="userinput">
   <label>City </label>
   <select name="city">
    <option value="1">Lahore</option>
    <option value="2">Karachi</option>
    <option value="3">Islamabad </option>
  <div style="text-align:center">
   <input type="reset" class="sampleBtn"/>
   <input type="submit" class="sampleBtn"/>   


Add styles such that the form shall look like this (form.png):

Here is guideline for you to decide what style properties you need to apply. (form-help.png)


After above form, please create as-is webpage that shall look like a facebook login form.