0% found this document useful (0 votes)
13 views3 pages

HTML & JavaScript Code Examples

The document contains practical examples of HTML and JavaScript code, showcasing various web elements such as a website survey, basic HTML elements, a class timetable, a profile page, CSS styling, and JavaScript functionalities like leap year checking and temperature conversion. Each section includes the HTML code and a brief description of the output. Additionally, it features a signup form with validation to check user input.

Uploaded by

vanshtyagi676
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

HTML & JavaScript Code Examples

The document contains practical examples of HTML and JavaScript code, showcasing various web elements such as a website survey, basic HTML elements, a class timetable, a profile page, CSS styling, and JavaScript functionalities like leap year checking and temperature conversion. Each section includes the HTML code and a brief description of the output. Additionally, it features a signup form with validation to check user input.

Uploaded by

vanshtyagi676
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HTML & JavaScript Practical – Code and Output

1. Survey Document of 10 Websites


HTML Code:
<html>
<body>
<h2>Website Survey</h2>
<ul>
<li>Google – Fast search engine.</li>
<li>YouTube – Video learning.</li>
<li>Wikipedia – Reference source.</li>
<li>Amazon – Online shopping.</li>
<li>Flipkart – E■commerce.</li>
<li>Instagram – Social media.</li>
<li>Twitter – News updates.</li>
<li>LinkedIn – Professional networking.</li>
<li>GitHub – Code hosting.</li>
<li>Reddit – Discussion platform.</li>
</ul>
</body>
</html>

Output:
A webpage showing a list of 10 websites with reasons.

2. Basic HTML Elements


HTML Code:
<html>
<body>
<h1>Heading 1</h1>
<p>This is a paragraph.</p>
<b>Bold Text</b><br>
<i>Italic Text</i><br>
<u>Underlined Text</u>
</body>
</html>

Output:
Displays heading, paragraph and styled text.

3. Table Tag – Class Timetable


HTML Code:
<html>
<body>
<h2>Class Timetable</h2>
<table border="1">
<tr><th>Day</th><th>Subject</th></tr>
<tr><td>Mon</td><td>Maths</td></tr>
<tr><td>Tue</td><td>Physics</td></tr>
</table>
</body>
</html>

Output:
A bordered timetable table.

4. Profile Page
HTML Code:
<html>
<body>
<h2>My Profile</h2>
<p>Name: Student</p>
<p>Hobbies: Reading, Music</p>
<p>Achievements: Certificate holder</p>
</body>
</html>

Output:
Simple personal profile webpage.

5. CSS Style Sheet


HTML Code:
<style>
p { color: blue; font-size: 20px; }
</style>
<p>This is styled text.</p>

Output:
Paragraph text appears blue and large.

6. JavaScript – Leap Year Check


HTML Code:
<script>
let y = 2024;
if((y%4==0 && y%100!=0) || y%400==0)
[Link]("Leap Year");
else
[Link]("Not Leap Year");
</script>

Output:
Leap Year

7. JavaScript – Temperature Conversion


HTML Code:
<script>
let c = 25;
let f = (c * 9/5) + 32;
[Link]("Fahrenheit = " + f);
</script>

Output:
Fahrenheit = 77

8. Signup Form Validation


HTML Code:
<html>
<body>
<form>
<input type="text" id="user" placeholder="Username"><br>
<input type="password" id="pass" placeholder="Password"><br>
<input type="text" id="phone" placeholder="Phone"><br>
<button onclick="validate()">Submit</button>
</form>

<script>
function validate(){
let u=[Link]('user').value;
let p=[Link]('pass').value;
let ph=[Link]('phone').value;
if(u=="" || p=="" || [Link]!=10)
alert("Invalid Input");
else
alert("Successful");
}
</script>
</body>
</html>

Output:
Alerts user whether input is valid.

You might also like