CSC336 Web Technologies LAB04
CSC336 Web Technologies LAB04
Activity Outcomes:
After this lab the students should be able to apply CSS to the web pages.
Instructor Note:
As pre-lab activity, read Chapter 4 from the textbook “Web Design Playground: HTML & CSS the
Interactive Way 1st Edition, April 2019 by Paul McFedries”.
1. Useful Concepts
Introduction
CSS stands for Cascading Style Sheets. It is a way to style HTML webpages. A style sheet is the
presentation of an HTML document. CSS is a style language that defines layout of HTML
documents. For example, CSS covers fonts, colours, margins, lines, height, width, background
images, advanced positions and many other things. CSS can be written either inside the html tags
(i.e. Inline), in the
<head></head> section of an HTML document (i.e. Internal) or in a separate CSS File (i.e.
External).
27
For inline styling CSS is written inside the style attribute of a tag. For example,
<tag style=”property:value”></tag>
For Internal styling, CSS is written into the head section of the HTML document. For example,
<style>
.class
property:value;
</style>
For external styling, CSS is written as a separate file and the file is saved with an extension .css.
In external style sheets the style tags are not necessary. Whereas, external CSS follow the same
structure as the Internal CSS does.
Basic CSS Properties Font Properties
Font Family Font Style Font Variant Font Weight
28
Background Image Background Repeat Background Position
Text Properties
Word Spacing Letter Spacing Text Decoration Vertical Alignment Line Height
Box Properties
Internal CSS:
<html>
<head>
<title>Internal CSS</title>
<style> h1{color:#FF0000; font-family:Calibri; font-size:36px
}
</style>
</head>
<body>
<h1>This heading is styled with CSS</h1>
</body>
29
</html>
External CSS:
Activity 1-4:
3. Use the html page created in Lab 2 (page for COMSATS) and create an external style-sheet
which style the elements of the page including style for
Solution:
body {
background-color: lightblue;
h1 {
font-size: 50px;
#para1 {
30
text-align: center; color: red;
.center {
<!DOCTYPE html>
<html>
<style>
* {box-sizing: border-box}
input[type=text], input[type=password] {
width: 100%;
padding: 15px;
display: inline-block;
border: none;
background: #f1f1f1;
input[type=text]:focus, input[type=password]:focus {
background-color: #ddd;
outline: none;
hr {
31
border: 1px solid #f1f1f1;
margin-bottom: 25px;
button {
background-color: #04AA6D;
color: white;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
button:hover {
opacity:1;
.cancelbtn {
background-color: #f44336;
.cancelbtn, .signupbtn {
32
float: left;
width: 50%;
.container {
padding: 16px;
/* Clear floats */
.clearfix::after {
content: "";
clear: both;
display: table;
/* Change styles for cancel button and signup button on extra small screens */
.cancelbtn, .signupbtn {
width: 100%;
</style>
<body>
<div class="container">
<h1>Sign Up</h1>
33
<p>Please fill in this form to create an account.</p>
<hr>
<label for="email"><b>Email</b></label>
<label for="psw"><b>Password</b></label>
<label>
</label>
<p>By creating an account you agree to our <a href="#" style="color:dodgerblue">Terms &
Privacy</a>.</p>
<div class="clearfix">
</div>
</div>
</form>
</body>
</html>
34
4. Graded Lab Tasks
Lab Task 1
Design the web template given below using tables and external CSS
Lab Task 2
Design the web template given below using tables and external CSS
35
36