Sei sulla pagina 1di 27

1. Write HTML code to Li tag .

<!DOCTYPE html> <html> <body> <p>An ordered list:</p> <ol> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ol> <p>An unordered list:</p> <ul> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> </body> </html>

Output;An ordered list: 1. Coffee 2. Tea 3. Milk An unordered list: Coffee Tea Milk

2. Write HTML code to implement Table tag.


<!DOCTYPE html> <html> <body> <table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table> </body> </html>

Output:Month Savings January $100 February $80

3. Write a HTML code to implement img tag.


<!DOCTYPE html> <html> <head> <title>This is Image of smile</title> </head> <body>

<img src="smiley.gif" alt="Smiley face" width="42" height="42">

</body> </html> Output:-

4. Write a HTML code to implement Frame.


<!DOCTYPE html> <html> <head> <title>This is a Frame</title> </html> <frameset cols="25%,*,25%"> <frame src="frame_a.htm"> <frame src="frame_b.htm"> <frame src="frame_c.htm"> </frameset>

</html>

Output:-

5. Write a HTML code to implement Form.


<!DOCTYPE html> <html> <head> <title>This is a From</title> </head> <body>

<form action="demo_form.asp"> First name: <input type="text" name="FirstName" value="Mickey"><br> Last name: <input type="text" name="LastName" value="Mouse"><br> <input type="submit" value="Submit"> </form>

<p>Click the "Submit" button and the form-data will be sent to a page on the server called .</p>

</body> </html>

Output:First name: Last name:


Submit
Mickey Mouse

Click the "Submit" button and the form-data will be sent to a page on the server called.

6. Write a CSS code to implement Background property.


<!DOCTYPE html> <html> <head> <style> body { background-color:#b0c4de; } </style> </head> <body> <h1>My CSS web page!</h1> <p>Hello world! This is a W3Schools.com example.</p> </body> </html>

Output:-

7. Write a CSS code to implement Text property.


<!DOCTYPE html> <html> <head> <style> body {color:red;} h1 {color:#00ff00;} p.ex {color:rgb(0,0,255);} </style> </head>

<body> <h1>This is heading 1</h1> <p>This is an ordinary paragraph. Notice that this text is red. The default text-color for a page is defined in the body selector.</p> <p class="ex">This is a paragraph with class="ex". This text is blue.</p> </body> </html>

Output:-

This is heading 1
This is an ordinary paragraph. Notice that this text is red. The default text-color for a page is defined in the body selector. This is a paragraph with class="ex". This text is blue.

8. Write a CSS code to implement Font property.


<!DOCTYPE html> <html> <head> <style> p.normal {font-style:normal;} p.italic {font-style:italic;} p.oblique {font-style:oblique;} </style> </head>

<body> <p class="normal">This is a paragraph, normal.</p> <p class="italic">This is a paragraph, italic.</p> <p class="oblique">This is a paragraph, oblique.</p> </body>

</html>

Output:This is a paragraph, normal. This is a paragraph, italic. This is a paragraph, oblique.

9. Write a CSS code for Table.


<!DOCTYPE html> <html> <head> <style> table { border-collapse:collapse; } table, td, th { border:1px solid black; } </style> </head> <body> <table> <tr> <th>Firstname</th> <th>Lastname</th> </tr> <tr> <td>Peter</td> <td>Griffin</td> </tr> <tr> <td>Lois</td> <td>Griffin</td>

</tr> </table> <p><b>Note:</b> If a !DOCTYPE is not specified, the border-collapse property can produce unexpected results in IE8 and earlier versions.</p> </body> </html>

Output:Firstname Lastname Peter Griffin Lois Griffin Note: If a !DOCTYPE is not specified, the border-collapse property can produce unexpected results in IE8 and earlier versions.

10. Write a CSS code for Border.


<!DOCTYPE html> <html> <head> <style> p.one { border-style:solid; border-width:5px; } p.two { border-style:solid; border-width:medium; } p.three { border-style:solid; border-width:1px; } </style> </head> <body> <p class="one">Some text.</p> <p class="two">Some text.</p> <p class="three">Some text.</p>

<p><b>Note:</b> The "border-width" property does not work if it is used alone. Use the "border-style" property to set the borders first.</p> </body> </html>

Output:Some text. Some text. Some text. Note: The "border-width" property does not work if it is used alone. Use the "border-style" property to set the borders first.

11. Write a javascript code for output statement.


<!DOCTYPE html> <html> <body>

<script> var pi=3.14; var person="John Doe"; var answer='Yes I am!';

document.write(pi + "<br>"); document.write(person + "<br>"); document.write(answer + "<br>"); </script>

</body> </html>

Output:3.14 John Doe Yes I am!

12. Write a javascript code for Function implementation.


<!DOCTYPE html> <html> <body>

<p>Click the button to call a function with arguments</p>

<button onclick="myFunction('Harry Potter','Wizard')">Try it</button>

<script> function myFunction(name,job) { alert("Welcome " + name + ", the " + job); } </script>

</body> </html>

Output:-

13. Write a javascript code to implement if else statement .


<!DOCTYPE html> <html> <body>

<p>Click the button to get a time-based greeting.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script> function myFunction() { var x=""; var time=new Date().getHours(); if (time<10) { x="Good morning"; } else if (time<20) { x="Good day"; } else { x="Good evening"; }

document.getElementById("demo").innerHTML=x; } </script>

</body> </html>

Output:-

14. Write a javascript code to implement while loop .


<!DOCTYPE html> <html> <body> </p> <button onclick="myFunction()">Try it</button> <p id="demo"></p>

<script> function myFunction() { var x="",i=0; while (i<5) { x=x + "The number is " + i + "<br>"; i++; } document.getElementById("demo").innerHTML=x; } </script>

</body> </html>

Output:-

15. Write a javascript code to implement switch case statement .


<html> <body>

<p>Click the button to display a message based on what day it is today.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script> function myFunction() { var x; var d=new Date().getDay(); switch (d) { case 6: x="Today it's Saturday"; break; case 0: x="Today it's Sunday"; break; default: x="Looking forward to the Weekend"; } document.getElementById("demo").innerHTML=x; }

</script>

</body> </html>

Output:-

16. Write a javascript code to implement RequredFieldValidation .


<!DOCTYPE html> <html> <head> <script> function validateForm() { var x=document.forms["myForm"]["fname"].value; if (x==null || x=="") { alert("First name must be filled out"); return false; } } </script> </head>

<body> <form name="myForm" onsubmit="return validateForm()" method="post"> First name: <input type="text" name="fname"> <input type="submit" value="Submit"> </form> </body>

</html>

Output:

17. Write PHP code to implement print statement .


<!DOCTYPE html> <html> <body> <?php echo "My first PHP script!"; ?> </body> </html>

Output:-

18. Write PHP code to implement string.


<!DOCTYPE html> <html> <body> <?php echo strpos("Hello world!","world"); ?> </body> </html>

Output:-

19. Write PHP code to implement Function.


<!DOCTYPE html> <html> <body> <?php function sum($x,$y) { $z=$x+$y; return $z; } echo "5 + 10 = " . sum(5,10) . "<br>"; echo "7 + 13 = " . sum(7,13) . "<br>"; echo "2 + 4 = " . sum(2,4); ?> </body> </html>

Output:-

20. Write PHP code to implement Array.


<!DOCTYPE html> <html> <body> <?php $cars=array("Volvo","BMW","Toyota"); echo count($cars); ?> </body> </html>

Output:-

S.no. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

PROGRAM NAME

Signature

Write HTML code to Li tag . Write HTML code to implement Table tag. Write a HTML code to implement img tag. Write a HTML code to implement Frame. Write a HTML code to implement Form.
Write a CSS code to implement Background property.

Write a CSS code to implement Text property. Write a CSS code to implement Font property. Write a CSS code for Table. Write a CSS code for Border. Write a javascript code for output statement.
Write a javascript code for Function implementation. Write a javascript code to implement if else statement .

Write a javascript code to implement while loop .


Write a javascript code to implement switch case statement . Write a javascript code to implement RequredFieldValidation .

18 19 20

Write PHP code to implement print statement . Write PHP code to implement string. Write PHP code to implement Function. Write PHP code to implement Array.

Potrebbero piacerti anche