Viva Internet
Viva Internet
HTML stands for HyperText Markup Language and is the language of the internet. It is the standard
text formatting language used for creating and displaying pages on the Internet
HTML documents are made up of the elements and the tags that format it for proper display on
pages.
We use HTML tags for placing the elements in the proper and appropriate format. Tags use the
symbols <, and > to set them apart from the HTML content.
The HTML tags need not be closed always. For example, in the case of images, the closing tags are
not required as <img> tag.
Attributes are the properties that can be added to an HTML tag. These attributes change the way the
tag behaves or is displayed. For example, a <img> tag has an src attribute, which you use to add the
source from which the image should be displayed.
We add attributes right after the name of the HTML tag, inside the brackets. We can only add the
attributes to opening or self-closing tags, but never be in closing tags.
Marquee is used for scrolling text on a web page. It scrolls the image or text up, down, left, or right
automatically. To apply for a marquee, you have to use </marquee> tags.
• Ordered list–The ordered list uses <ol> tag and displays elements in a numbered format.
• Unordered list–The unordered list uses <ul> tag and displays elements in a bulleted format.
• Definition list–The definition list uses <dl>, <dt>, <dd> tags and displays elements in definition
form like in a dictionary.
We can align the list elements in an HTML file by using indents. If you indent each nested list in
further than the parent list, you can easily align and determine the various lists and the elements that
it contains.
• Comprehensive Blended Learning program 8X higher interaction in live online classes conducted by
industry experts
11 months
View Program
•
• Kickstart Full Stack Java Developer career with industry- Hands-on practice through 20+ projects, assessments, and
aligned curriculum by experts tests
6 months
View Program
Not sure what you’re looking for? View all Related Programs
An unordered list uses <ul> </ul> tags and each element of the list is written between <li> </li>
tags. The list items are displayed as bullets rather than numbers.
An ordered list uses <ol> </ol> tags and each element of the list is written between <li> </li> tags.
The list items are displayed as numbers rather than bullet points.
<!DOCTYPE html>
<html>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
An element in HTML is a set of tags that define a specific part of a web page. It consists of a start
tag, content, and an end tag.
HTML is used to create the structure and content of a web page, while CSS is used to define the
appearance and layout of the page.
Object 1
11. Are the HTML tags and elements the same thing?
No, HTML tags are used to define the structure of a web page, while HTML elements are made up
of a set of tags that define a specific part of a web page.
Void elements in HTML are tags that do not require a closing tag. They are used to insert images,
line breaks, and other content that does not require additional information.
Collapsing white space in HTML can help to reduce the size of web pages and make them load
faster. It involves removing unnecessary white space between HTML elements.
HTML Entities are special characters used to represent characters that cannot be typed on a
keyboard. They are often used to display special symbols and foreign characters.
15. How do you display a table in an HTML webpage?
The HTML <table> tag is used to display data in a tabular format. It is also used to manage the
layout of the page, for example, header section, navigation bar, body content, footer section. Given
below are the list of HTML tags used for displaying a table in an HTML webpage:
Tag Description
16. How would you display the given table on an HTML webpage?
5 1
pcs 0
1 5
pcs 0
<table>
<tr>
<td>50 pcs</td>
<td>100</td>
<td>500</td>
</tr>
<tr>
<td>10 pcs</td>
<td>5</td>
<td>50</td>
</tr>
</table>
We can insert a comment in HTML by beginning with a lesser than sign and ending with a greater
than sign. For example, “<!-“ and “->.”
You can insert a copyright symbol by using © or © in an HTML file.
An empty sequence of space characters is called the white space in HTML. This white space is
considered as a single space character in the HTML.
White space helps the browser to merge multiple spaces into one single space, and so taking care of
indentation becomes easier. White space helps in better organizing the content and tags, making
them readable and easy to understand.
20. How do you create links to different sections within the same HTML web page?
We use the <a> tag, along with referencing through the use of the # symbol, to create several links
to different sections within the same web page.
21. How do you create a hyperlink in HTML?
We use the anchor tag <a> to create a hyperlink in HTML that links one page to another page. The
hyperlink can be added to images too.
• Comprehensive Blended Learning program 8X higher interaction in live online classes conducted by
industry experts
11 months
View Program
• Kickstart Full Stack Java Developer career with industry- Hands-on practice through 20+ projects, assessments, and
aligned curriculum by experts tests
6 months
View Program
Not sure what you’re looking for? View all Related Programs
22. Define an image map?
An image map in HTML helps in linking with the different kinds of web pages using a single
image. It can be used for defining shapes in the images that are made part of the image mapping
process.
A style sheet helps in creating a well-defined template for an HTML webpage that is both consistent
as well as portable. We can link a single style sheet template to various web pages, which makes it
easier to maintain and change the look of the website.
Semantic HTML is a coding style. It is the use of HTML markup to reinforce the semantics or
meaning of the content.
For example: In semantic HTML <b> </b> tag is not used for bold statement as well as <i> </i> tag
is not used for italic. Instead of these we use <strong></strong> and <em></em> tags.
HTML SVG is used to describe the vector or raster graphics. SVG images and their behaviors are
defined in XML text files.
We mostly use it for vector type diagrams like pie charts, 2-Dimensional graphs in an X, Y
coordinate system.
</svg>
26. What would happen if there is no text between the HTML tags?
There would be nothing to format if there is no text present between the tags. Therefore, nothing
will appear on the screen.
Some tags, such as the tags without a closing tag like the <img> tag, do not require any text
between them.
Nested web pages basically mean a webpage within a webpage. We can create nested web pages in
HTML using the built-in iframe tag. The HTML <iframe> tag defines an inline frame. For example:
<!DOCTYPE html>
<html>
<body>
<p>
specify the size of the iframe using the height and width attributes:
</p>
</body>
</html>
28. How do you add buttons in HTML?
We can use the built-in Button tag in HTML to add buttons to an HTML web page.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
There are six types of heading tags in HTML which are defined with the <h1> to <h6> tags. Each
type of heading tag displays a different text size from another. <h1> is the largest heading tag and
<h6> is the smallest. For example:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
You can insert an image in the HTML webpage by using the following code:
<!DOCTYPE html>
<html>
<body>
</html>
The alt attribute is used for displaying a text in place of an image whenever the image cannot be
loaded due to any technical issue.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
• Comprehensive Blended Learning program 8X higher interaction in live online classes conducted by
industry experts
11 months
View Program
• Kickstart Full Stack Java Developer career with industry- Hands-on practice through 20+ projects, assessments, and
aligned curriculum by experts tests
6 months
View Program
Not sure what you’re looking for? View all Related Programs
You can insert a hyperlink in the HTML webpage by using the following code:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
32. How do you add colour to the text in HTML?
You can add colour to the text in HTML by using the following code:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
• Inline CSS: It is used when less amount of styling is needed or in cases where only a single
element has to be styled. To use inline styles add the style attribute in the relevant tag.
• External Style Sheet: This is used when the style is applied to many elements or HTML pages.
Each page must link to the style sheet using the <link> tag:
<head>
</head>
• Internal Style Sheet: It is used when a single HTML document has a unique style and several
elements need to be styled to follow the format. Internal styles sheet is added in the head section
of an HTML page, by using the <style> tag:
<head>
<style type="text/css">
hr {
color: sienna;
p{
margin-left: 20px;
body {
background-image: url("images/back40.gif");
</style>
</head>
If a single selector includes three different style definitions, the definition that is closest to the
actual tag takes precedence. Inline style takes priority over embedded style sheets, which takes
priority over external style sheets.
35. How do you add JavaScript to an HTML webpage?
JavaScript is used for making HTML web pages more interactive, and user-friendly. It is a scripting
language that allows you to interact with certain elements on the page, based on user input. As with
CSS, there are three major ways of including JavaScript:
• Inline:
You can add JavaScript to your HTML elements directly whenever a certain event occurs. We can
add the JavaScript code using attributes of the HTML tags that support it. Here is an example that
shows an alert with a message when the user clicks on it:
Click!
</button>
• Script block:
You can define a script block anywhere on the HTML code, which will get executed as soon as the
browser reaches that part of the document. This is why script blocks are usually added at the bottom
of HTML documents.
<html>
<script>
var x = 1;
var y = 2;
var result = x + y;
</script>
</html>
You can also import the JavaScript code from a separate file and keep your HTML code clutter-free.
This is especially useful if there is a large amount of scripting added to an HTML webpage.
<html>
<script src="my-script.js"></script>
</html>
There are three lists in HTML: ordered, unordered, and definition. Ordered lists are numbered lists,
unordered lists are bulleted lists, and definition lists are lists of terms and their definitions.
The ‘class' attribute in HTML defines a class for an HTML element. It can be used to apply a
specific style to a group of elements on a web page.
38. What is the difference between the ‘id' and ‘class' attributes of HTML
elements?
The ‘id' attribute defines a unique identifier for an HTML element, while the ‘class' attribute defines
a class for a group of elements. An ‘id' can only be used once on a page, while a ‘class' can be used
multiple times.
39. What is the difference between HTML and XHTML?
HTML and XHTML are both markup languages used to create web pages. However, XHTML is
stricter than HTML and requires developers to write well-formed code that adheres to specific rules
and guidelines. XHTML also requires all tags to be closed and all attributes to be quoted.
HTML5 is the latest version of HTML and includes new features and improvements over previous
versions. Some key differences between HTML and HTML5 include support for multimedia
elements (such as video and audio), improved semantics, and better support for mobile devices.
The <head> tag defines information about the web page that is not displayed on the page itself, such
as its title, keywords, and other metadata. It is located between the <html> and <body> tags and is
usually the first element in the document.
The <meta> tag provides additional information about the web page, such as the author, description,
and keywords. It is located within the <head> section of the HTML document.
An absolute URL includes the full web address, the protocol (such as http or https) and the domain
name (such as www.example.com). A relative URL, on the other hand, specifies the location of a
resource relative to the current web page. For example, a relative URL might include the file path
(such as /images/picture.jpg) or the relative path (such as ../images/picture.jpg).
44. What is the role of the alt attribute in HTML?
The alt attribute provides alternative text for an image in case the image cannot be displayed. This is
important for accessibility, as screen readers can read the alt text to describe the image to visually
impaired users.
The title attribute provides additional information about an element, such as a link or an image. The
title text is displayed as a tooltip when a user hovers over the element.
A form is a set of input fields and other elements to collect user data. Forms can be used for various
purposes, such as logging in, submitting feedback, or purchasing.
47. What are the different types of form input fields in HTML?
Several form input fields in HTML include text fields, checkboxes, radio buttons, select menus, and
text areas. Each input field type is used to collect different types of data from users.
The action attribute is used to specify the URL of the script or program that will process the data
submitted by the form. When the user clicks the submit button, the form data is sent to the specified
URL for processing.
49. What is the role of the method attribute in HTML forms?
The method attribute is used to specify the HTTP method that will be used to submit the form data.
The two most common methods are GET and POST. GET is used to retrieve data from the server,
while POST is used to send data to the server
HTML elements can be displayed in several ways, including block, inline, inline-block, and none.
The display property can specify how an element should be displayed.
51. What is the difference between “display: none” and “visibility: hidden” when
used as attributes to the HTML element?
The main difference between “display: none” and “visibility: hidden” is that the former removes the
element from the document flow, while the latter simply hides it. Elements with “display: none” are
not visible and do not take up any space on the page, while elements with “visibility: hidden” are
not visible but still take up space.
52. How to specify the link in HTML and explain the target attribute?
Links can be specified using the <a> tag. The href attribute is used to specify the URL of the page
that the link should go to. The target attribute can specify where the linked page should open, such
as in a new or similar window.
53. In how many ways can we specify the CSS styles for the HTML element?
CSS styles can be specified in several ways, including inline, internal, and external stylesheets.
Inline styles are applied directly to the HTML element using the style attribute. Internal styles are
defined within the <head> section of the HTML document using the <style> tag. External
stylesheets are defined in a separate CSS file and linked to the HTML document using the <link>
tag.
54. What is the difference between link tag <link> and anchor tag <a>?
The <link> tag links external resources, such as CSS stylesheets, to an HTML document. The <a>
tag creates links to other pages or resources within the same document.
55. When to use scripts in the head and when to use scripts in the body?
Scripts can be placed in the <head> section of the HTML document or in the <body> section.
Scripts that must be executed before the page is displayed, such as scripts that define variables or
functions, should be placed in the <head> section. Scripts that must be executed after the page is
displayed, such as scripts that manipulate the DOM, should be placed in the <body> section.
Forms collect user data, such as login information or search queries. Forms can be created using the
<form> tag, and input fields, such as text fields and checkboxes, can be added using various other
tags.
Events can be handled using JavaScript, which can be included in the HTML document using the
<script> tag. Event listeners can be added to HTML elements using the addEventListener() method,
which allows custom code to be executed in response to user actions, such as clicks or keystrokes.
58. What are some advantages of HTML5 over its previous versions?
HTML5 includes several new features and improvements over previous versions, including better
multimedia support, semantic elements, and better support for mobile devices. HTML5 also
includes new APIs for working with web applications, such as the Geolocation API and the Canvas
API.