CSS and Java Script Lab Programs
CSS and Java Script Lab Programs
Aim: To create a webpage to show different character formatting (B, I, U, SUB, SUP) tags.
viz : log b m p = p log b m
Source code
<html>
<head>
<title>Character formatting</title>
</head>
<body>
<p> <b> <i> log</i></b> <sub>b </sub>m<sup> p</sup> =p<b> <i> log </i>
</b><sub>b</sub> m</p>
</body>
</html>
• The <style> tag for css to apply styles for body, h1, p tags
• The <audio> tag is used to embed sound content in a document, such as music or other
audio streams.
Source code
<html>
<body>
<style>
body {
background-color:blue;
}
h1 {
color:orange;
text-align:center;
}
p {
font-family: "Times New Roman";
font-size: 20px;
}
</style>
<h1>My First CSS Example</h1>
<p>This is a audio.</p>
<audio controls>
<source src="horse.mp3">
</audio>
</body>
</html>
Source code
<html>
<head>
<title>CSS Example</title>
<!-- Internal CSS -->
<style>
/* Internal CSS */
h1 {
color: blue;
}
p {
font-size: 16px;
}
</style>
<!-- External CSS -->
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<!-- Inline CSS -->
<h1 style="font-family: Arial, sans-serif;">Inline CSS Example</h1>
<p style="color: green;">This is a paragraph with inline CSS.</p>
<!-- Internal CSS -->
<h1>Internal CSS Example</h1>
<p>This is a paragraph with internal CSS.</p>
<!-- External CSS -->
<h1 class="external">External CSS Example</h1>
<p class="external">This is a paragraph with external CSS.</p>
</body>
</html>
styles.css
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p {
color: red;
}
Source Code:
<html>
<head>
<title> Java Script Even_Odd</title>
</head>
<body>
<script>
</script>
</body>
</html>
Source Code:
<html>
<head>
<title> Java Script Greatest_Num</title>
</head>
<body>
<script>
Source Code:
<html>
<head>
<title> Java Script Square_root</title>
</head>
<body>
<script>
let num=parseint(prompt("Enter the number: ")); let
root=Math.sqrt(num);
document.write("Square root of "+num+" is "+root);
</script>
</body>
</html>
Source Code:
<html>
<head>
<title> Java Script Age_Form</title>
</head>
<body>
<form name="ageForm">
<h2>Age Form</h2>
<input type="text" name="username" placeholder="Enter your name"><br><br>
<input type="text" name="userage" placeholder="Enter your age"><br><br>
<input type="submit" onclick="agefn()">
</form>
<script>
function agefn()
{
let usr_name=document.ageForm.username.value; let
usr_age=document.ageForm.userage.value;
if(usr_age>=18)
document.write(usr_name+'', You are eligible to vote");
else
document.write(usr_name+", You are ineligible to vote");
</body> </script>
</html>