HTML Interview Questions
This page contains HTML interview questions and answers.
An image map is an image with some defined shapes that are linked to some web pages. So, when we click on the shape drawn on the image we are taken to some website page.
To create tables in HTML we use the table
tag.
In the following example we are creating a table having 3 rows and 2 columns.
<table border="1">
<tr>
<th>Team</th>
<th>Score</th>
</tr>
<tr>
<td>A</td>
<td>10</td>
</tr>
<tr>
<td>B</td>
<td>10.2</td>
</tr>
</table>
Team | Score |
---|---|
A | 10 |
B | 10.2 |
To solve this we will first create an anchor tag a
at the beginning of the page ideally close to the body
tag. And we will set the name
attribute of the anchor tag to lets say back-to-top
.
<a name="back-to-top"></a>
Now we create another anchor tag in the page from were we want to jump back to the top of the page and we set the href
attribute to #back-to-top
.
<a href="#back-to-top">Back to top</a>
Now if the user clicks the Back to top
link the page will scroll back to the top of the page.
One way of doing this is by enclosing the word in a span
tags and then use the style
attribute and set the color to the desired value.
In the following example we are changing the color of the word super to blue.
<p>This is <span style="color: blue;">super</span>!</p>
This is super!
HTML attributes are added in the opening tag and they provide additional information about the element.
In the following example we have an img
tag and it has 5 attributes.
<img class="super-image"
src="path/to/image.png"
width=200
height=30
alt="logo">
There are some attributes that can take any value. Then there are some that can take only specific values and we also have some that needs no value.
For example src
, value
, alt
are some attributes that can take any value.
Then, we have attributes like autocomplete
which can take either on
and off
value.
And required
, disabled
, autofocus
are some attributes that can be added to the input field without specifying any value.
To solve this we have to add the target
attribute to the a
tag and set the value to _blank
.
<a href="https://dyclassroom.com" alt="dyclassroom" target="_blank">Open link in new tab</a>
Chrome, Safari, Edge, Firefox are some of the web browsers.
Yes. By adding bgcolor
attribute in the opening body
tag and setting its value to some color we can change the background color of the HTML page.
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body bgcolor="lightskyblue">
<h1>Hello World</h1>
</body>
</html>
To set the dimensions of an image we use the width
and height
attributes.
In the following example we are setting the width and height of an image to 200 pixels and 30 pixels respectively.
<img src="path/to/image.png" alt="brand-logo" width=200 height=30>
ADVERTISEMENT