p16065 File
p16065 File
Practical-1
Introduction to CSS :
CSS Syntax :
SPCE(IT) 1
AWP(3161611) 221240116065
External CSS
- With an external style sheet, you can change the look of an entire website by
changing just one file!
- Each HTML page must include a reference to the external style sheet file
inside the element, inside the head section.
Internal CSS
- An internal style sheet may be used if one single HTML page has a unique
style.
- The internal style is defined inside the <style>element, inside the head
section.
Inline CSS
- An inline style may be used to apply a unique style for a single element.
- To use inline styles, add the style attribute to the relevant element. The style
attribute can contain any CSS property.
CSS selectors :
- Css selectors are used to select the content you want to style. Selectors are the part
of CSS rule set. CSS selectors select HTML elements according to its id, class,
type, attribute etc.
CSS Id Selector
- The id selector uses the id attribute of an HTML element to select a specific
element.
- The id of an element is unique within a page, so the id selector is used to
select one unique element!
- To select an element with a specific id, write a hash (#) character, followed
by the id of the element.
- Example :
#para1 {
text-align: center;
color: red;
}
SPCE(IT) 2
AWP(3161611) 221240116065
SPCE(IT) 3
AWP(3161611) 221240116065
OUTPUT :
<html>
<head>
<title>Practical-1</title>
<style>
body{
background-color:black;
}
h1,h2,p{
text-align:center;
color:white;
}
</style>
</head>
<body>
<h1><p>Introduction of css</p></h1>
<h2>what is css?</h2>
<h2>css syntex</h2>
<h2>Types of css</h2>
<h2>css selectors</h2>
</body>
</html>
SPCE(IT) 4
AWP(3161611) 221240116065
OUTPUT :
SPCE(IT) 5
AWP(3161611) 221240116065
Practical – 2
AIM: Write a program to display current date and time using CSS.
<html>
<head>
<title>Date and Time</title></br></br>
</head>
<style>
Body{
background-color :white;
justify-content: center;
}
</style>
<body>
<div class="Example">Date and Time</div></br>
<button type ="button"
onclick="document.getElementById('demo').innerHTML=
Date();">
OUTPUT :
SPCE(IT) 6
AWP(3161611) 221240116065
Practical – 3
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
<script>
function validate() {
var name = document.f1.name.value;
var password = document.f1.password.value;
var status = true;
// Name validation
if (name.length < 1) {
document.getElementById("nameloc").innerHTML =
'<img src="unchecked.png" style="width:15px; height:15px;"/>Please enter
your name';
status = false;
} else {
document.getElementById("nameloc").innerHTML =
'<img src="checked.png" style="width:15px; height:15px;"/>';
}
// Password validation
if (password.length < 6) {
document.getElementById("passwordloc").innerHTML =
'<img src="unchecked.png" style="width:15px; height:15px;"/> Password
must be at least 6 characters';
status = false;
} else {
document.getElementById("passwordloc").innerHTML =
'<img src="checked.png" style="width:15px; height:15px;"/>';
}
return status; }
</script>
</head>
SPCE(IT) 7
AWP(3161611) 221240116065
<body>
<form name="f1" action="#" onsubmit="return validate()">
<table>
<tr>
<td>Enter your name :</td>
<td>
<input type="text" name="name"/>
<span id="nameloc"></span>
</td></tr>
<tr>
<td>Enter your password :</td>
<td>
<input type="password" name="password"/>
<span id="passwordloc"></span>
</td> </tr>
<tr><td colspan="2">
<input type="submit" value="Register"/>
</td></tr>
</table>
</form>
</body>
</html>
OUTPUT :
SPCE(IT) 8
AWP(3161611) 221240116065
SPCE(IT) 9