HTML CODING EXERCISES Coding For Beginner - JJ TAM
HTML CODING EXERCISES Coding For Beginner - JJ TAM
CODING EXERCISES
PHP Tutorial
Create a hyperlink in HTML
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to create a hyperlink</title>
</head>
<body>
<p><a href="http://htmlexample.com">htmlexample.com</a><p>
</body>
</html>
Download a file
when clicking on the link
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Download a file when clicking on the link</title>
</head>
<body>
<p><a href="https://www.hmlresource.com/images/htmlresource-
logo.png" download>Download</a></p>
</body>
</html>
Create a link
with a media attribute
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Create a link with a media attribute</title>
</head>
<body>
<a href="https://www.htmlresource.com" media="print, handheld">Media
Attribute</a>
</body>
</html>
Create a nofollow link
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to create a nofollow link</title>
</head>
<body>
<a rel="nofollow" href="http://htmlexample.com">Example.com</a>
</body>
</html>
Open a linked document
in a separate browser tab
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to open a linked document in a separate browser tab</title>
</head>
<body>
<p><a href="https://htmlresource.com" target="_blank">Target HTML5
EXCECISES</a></p>
</body>
</html>
Correct way to write address
in a HTML document
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>What is the correct way to write address in a HTML
document</title>
</head>
<body>
<address>
Address: 21,MG Road<br>
Burdwan<br>
West Bengal.
</address>
</body>
</html>
Specify an alternate text
for the area
if the href attribute is present
HTML CODE
<body>
<img src="https://www.htmlresource.com/htmlr_images/html-area-
element.png" alt="area example" border="0" usemap="#Map"/>
<map name="Map">
<area shape="rect" coords="8,5,100,77"
href="https://www.htmlresource.com/mysql/mysql-tutorials.php"
target="_blank" alt="mysql tutorial">
<area shape="circle" coords="155,93,59"
href="https://www.htmlresource.com/php/php-home.php" target="_blank"
alt="php tutorial">
<area shape="rect" coords="197,136,306,188"
href="https://www.htmlresource.com/sql/sql-tutorials.php" alt="sql
tutorials">
</map>
</body>
Create an HTML document
which uses article element
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Create an HTML document which uses article element</title>
</head>
<body>
<article>
<h1>Tutorial of HTML5 article element</h1>
<p>HTML5 article element represents independent item like a blog entry in
an web document.</p>
</article>
</body>
</html>
Create an HTML document
which uses aside element
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to create an HTML document which uses aside
element</title>
</head>
<body>
<p> I visited the HTML5 tutorial of htmlresource</p>
<aside>
<h4>HTML5 tutorial</h4>
<p>I can develop excellent web applications with HTML5 and related
APIs (like GeoLocation, Drag and Drop, WebSocket etc.)in HTML5
tutorial.</p>
</aside>
</body>
</html>
OUTPUT
I visited the HTML5 tutorial of htmlresource
HTML5 tutorial
I can develop excellent web applications with HTML5 and related
APIs (like GeoLocation, Drag and Drop, WebSocket etc.)in
HTML5 tutorial.
To add controls to an audio
HTML CODE
<body>
<audio controls>
<source src="https://www.htmlresource.com/html-css-
exercise/basic/solution/beach.ogg" type="audio/ogg">
<source src="https://www.htmlresource.com/html-css-
exercise/basic/solution/beach.mp3" type="audio/mpeg">
</audio>
</body>
Write bold text using HTML tags
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to write bold text using HTML tags</title>
</head>
<body>
<p>"htmlresource" is normal text - and <b>"htmlresource"</b> is bold
text.
</body>
</html>
OUTPUT
"htmlresource" is normal text - and "htmlresource" is bold text.
To specify the base URL
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to specifie the base URL/target for all relative URLs in a
document</title>
<base href="https://www.htmlresource.com/">
</head>
<body>
<ul>
<li><a href="php/php-home.php">PHP Tutorial</a></li>
<li><a href="javascript/javascript.php">JavaScript Tutorial</a></li>
<li><a href="mysql/mysql-tutorials.php">MySQL Tutorial</a></li>
</body>
</html>
Isolate a part of text
That might be formatted
In a different direction
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><span class="heading">How to isolate a part of text that might be
formatted in a different direction from other text outside it</span></title>
</head>
<body>
<p>
In the example below, usernames are shown along with the number of
points in a contest.
If the bdi element is not supported in the browser, the username of the
Arabic user would confuse the text (the bidirectional algorithm would put
the colon and the number "80" next to the word "User" rather than next to
the word "points").
</p>
<ul>
<li>User <bdi>hrefs</bdi>: 40 points</li>
<li>User <bdi>jdoe</bdi>: 60 points</li>
<li>User <bdi> < ﺗﺮﺣﻲ ب/bdi>:80 points</li>
</ul>
<p><b>Note:</b> The bdi element is currently supported only in Firefox
and Chrome.</p>
</body>
</html>
OUTPUT
In the example below, usernames are shown along with the number
of points in a contest. If the bdi element is not supported in the
browser, the username of the Arabic user would confuse the text
(the bidirectional algorithm would put the colon and the number
"80" next to the word "User" rather than next to the word "points").
User hrefs: 40 points
User jdoe: 60 points
User 80: ﺗﺮﺣﻴﺐpoints
OUTPUT
Specify one or more forms
the button belongs to
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to specify one or more forms the button belongs to</title>
</head>
<body>
<form method="POST"
action="https://www.htmlresource.com/html-css-
exercise/basic/solution/button-form-answer-demo.php" id="form1">
First name : <input type="text" name="fname"><br>
Last name : <input type="text" name="lname"><br>
Present Address : <input type="text" name="add"><br>
E-mail : <input type="text" name="mail"><br>
</form>
<button type="submit" form="form1" value="Submit">Submit</button>
</body>
</html>
OUTPUT
Specify where to send the form-
data
when a form is submitted
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to Specify where to send the form-data when a form is
submitted.</title>
</head>
<body>
<form action="https://www.htmlresource.com/html-css-
exercise/basic/solution/button-formaction-
answer-demo.php" method="post">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit">Submit</button><br>
<button type="submit" formaction="https://www.htmlresource.com/html-
css-
exercise/basic/solution/button-formaction-admin-demo.php">Submit as
admin</button>
</form>
</body>
</html>
OUTPUT
Send the form-data
(which HTTP method to use)
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to send the form-data,which HTTP method to use</title>
</head>
<body>
<form action="https://www.htmlresource.com/html-css-
exercise/basic/solution/button-formmethod-answer-demo.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
Address: <input type="text" name="place"><br>
<button type="submit">Submit</button>
<button type="submit" formmethod="post"
formaction="http://localhost/html-css-exercise/basic/solution/button-
formmethod-post-answer.php">Submit using POST</button>
</form>
</body>
</html>
OUTPUT
Specify where to display
the response after submitting the form
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to specify where to display the response after submitting the
form</title>
</head>
<body>
<form action="https://www.htmlresource.com/html-css-
exercise/basic/solution/button-formtarget-answer-demo.php"
method="POST">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit">Submit</button>
<button type="submit" formtarget="_blank">Submit to a new
window/tab</button>
</form>
</body>
</html>
OUTPUT
Specify a name for the button
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to specify a name for the button</title>
</head>
<body>
<form action="https://www.htmlresource.com/html-css-
exercise/basic/solution/button-name-answer-demo.php" method="post">
Choose your favorite topic:
<button name="topic" type="submit"
value="JavaScript">JavaScript</button>
<button name="topic" type="submit" value="PHP">PHP</button>
</form>
</body>
</html>
OUTPUT
Specify the type of button
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to specify the type of button</title>
</head>
<body>
<form action="https://www.htmlresource.com/html-css-
exercise/basic/solution/button-type-answer-demo.php"
method="post"id="nameform">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
Address: <input type="text" name="add"><br>
<button type="submit" value="Submit">Submit</button>
<button type="reset" value="Reset">Reset</button>
</form>
</body>
</html>
OUTPUT
Draw graphics, on the fly,
via scripting
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to use to draw graphics, on the fly, via scripting</title>
</head>
<body>
Canvas
<style>
#FirstCanvas{
width: 500px;
height: 300px;
border: 3px solid red;
background-color: blue;
}
</style>
<body>
<canvas id="FirstCanvas"></canvas>
</body>
</html>
OUTPUT
Define a table caption
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to define a table caption</title>
</head>
<body>
<table border="1">
<caption>First column holds Student code and second column holds
percentage of marks obtained by the student</caption>
<tr>
<th>Student code </th>
<th>% of marks </th>
</tr>
<tr>
<td>S001</td>
<td>85</td>
</tr>
<tr>
<td>S002</td>
<td>86</td>
</tr>
<tr>
<td>S003</td>
<td>72</td>
</tr>
<tr>
<td>S004</td>
<td>89</td>
</tr>
</table
</body>
</html>
OUTPUT
Specify the column properties
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to specify the column properties of each column within a
column group element</title>
</head>
<body>
<table class="table table-bordered">
<colgroup>
<col span="3" style="background-color:#cc66Ff">
<col style="background-color:#cc66Ff">
</colgroup>
<tr>
<th>COL-1</th>
<th>COL-2</th>
<th>COL-3</th>
</tr>
<tr>
<td>MySQL</td>
<td>PHP</td>
<td>SQL</td>
</tr>
<tr >
<td>MySQL Exercise</td>
<td>PHP Exercise</td>
<td>SQL Exercise</td>
</tr>
</table>
</body>
</html>
OUTPUT
Define important text
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to define important text</title>
</head>
<body>
<p>This is an example of <strong>HTML strong tag.</strong></p>
</body>
</html>
OUTPUT
This is an example of HTML strong tag.
Specify a list of pre-defined options
for input controls
HTML CODE
<!doctype html>
<html>
<head>
<title>HTML5 datalist example</title>
</head>
<body>
<input list="Languages" />
<datalist id="Languages">
<option value="PHP">
<option value="ASP">
<option value="Python">
<option value="Ruby">
<option value="Java">
</datalist>
</body>
</html>
OUTPUT
Define a description
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to define a description/value of a term in a description
list</title>
</head>
<body>
<dl>
<dt>PHP</dt>
<dd>A server side scripting language.</dd> <dt>JavaScript</dt>
<dd>A client side scripting language.</dd> </dl>
</body>
</html>
OUTPUT
PHP
A server side scripting language.
JavaScript
A client side scripting language.
Define a dialog box
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to define a dialog box or window</title>
</head>
<body>
<style>
table, th, td {
border: 1px solid red;
}
</style>
</head>
<body>
<table>
<tr>
<th>March <dialog open>This is an open dialog window</dialog></th>
<th>April</th>
<th>May</th>
</tr>
<tr>
<td>31</td>
<td>30</td>
<td>31</td>
</tr>
</table>
</body>
</html>
OUTPUT
Define a section
in a document
HTML CODE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>How to define a section in a document</title>
</head>
<body>
<div>
<h1>htmlresource Tutorial</h1>
<p>This is example of division</p>
</div>
</body>
</html>
OUTPUT
htmlresource Tutorial
This is example of division