0% found this document useful (0 votes)
1 views

HTML - Interview

The document provides a comprehensive overview of HTML, covering its definition, structure, and various components such as tags, attributes, and elements. It explains the differences between HTML and CSS, HTML and XHTML, and HTML and HTML5, as well as detailing how to create forms, hyperlinks, and style sheets. Additionally, it discusses JavaScript integration, event handling, and the use of various HTML tags for structuring web content.

Uploaded by

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

HTML - Interview

The document provides a comprehensive overview of HTML, covering its definition, structure, and various components such as tags, attributes, and elements. It explains the differences between HTML and CSS, HTML and XHTML, and HTML and HTML5, as well as detailing how to create forms, hyperlinks, and style sheets. Additionally, it discusses JavaScript integration, event handling, and the use of various HTML tags for structuring web content.

Uploaded by

mrpubg632
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

1. What is HTML?

HTML stands for Hypertext Markup Language, the language of the Internet. It is the standard
text formatting language used for creating and displaying pages on the Internet.
HTML documents comprise the elements and the tags that format it for proper page display.

2. What are HTML tags?


We use HTML tags to place 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 always be closed. For example, in the case of images, the closing tags
are not required as <img> tags.

3. What are HTML Attributes?


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 to closing tags.

4. What is a marquee in HTML?


A marquee in HTML is a tag used to create scrolling text or images across the screen.
Syntax: <marquee>Scrolling text here</marquee>
e.g: <marquee direction="right" scrollamount="5">
Welcome to my website!
</marquee>

5. How do you separate a section of text in HTML?


The list types in HTML are as follows:
● 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.

6. How do you align list elements in an HTML file?


We can align the list elements in an HTML file using indents. If you indent each nested list
further than the parent list, you can easily align and determine the various lists and their
elements.

7. What is an element in 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.

8. What is the difference between HTML and CSS?


HTML creates a web page's structure and content, while CSS defines its appearance and layout.

9. Are the HTML tags and elements the same thing?


No, HTML tags 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.

10. What are void elements in HTML?


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.

11. What is the advantage of collapsing white space?


Collapsing white space in HTML can help reduce web pages' size and make them load faster. It
involves removing unnecessary white space between HTML elements.
12. What are HTML Entities?
HTML Entities are special codes used in HTML to represent characters that have a specific
meaning in HTML or characters that might not be easily typed on a keybo
HTML entities are written as & followed by the name or number of the entity, and then a
semicolon (;).
&lt; → < (less-than sign)
&gt; → > (greater-than sign)
&amp; → & (ampersand)

13. How do you display a table in an HTML webpage?


The HTML <table> tag displays data in a tabular format. It is also used to manage the layout of
the page, for example, the header section, navigation bar, body content, and footer section. Given
below is the list of HTML tags used for displaying a table on an HTML webpage:
Basic Table Structure:
1. <table>: Defines the table itself.
2. <tr>: Defines a table row.
3. <th>: Defines a table header cell.
4. <td>: Defines a table data cell.
14. How do we insert a comment in HTML?
We can insert a comment in HTML by beginning with a lesser than sign and ending with a
greater than sign. For example, “<!-“ and “->.”

15. What is white space in HTML?


An empty sequence of space characters is called white space in HTML. It is considered a single-
space character.
White space helps the browser merge multiple spaces into one space, making indentation easier.
It also helps better organize the content and tags, making them readable and easily understood.

16. How do you create links to different sections within the same HTML web page?
We use the <a> tag and referencing through the # symbol to create several links to different
sections within the same web page.

17. 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. The
hyperlink can be added to images, too.

18. Why do we use a style sheet in HTML?


A style sheet helps create a well-defined, consistent, and portable HTML webpage template. We
can link a single style sheet template to various web pages, which makes it easier to maintain and
change the website's look.

19. What would happen without 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 those without a closing tag like the <img> tag, do not require any text
between them.
20. What is the alt attribute in HTML?
The alt attribute displays text in place of an image whenever the image cannot be loaded due to
technical issues.
<img src="tulip.jpeg" alt="Tulip Garden" />

21. How are hyperlinks inserted in the HTML webpage?

22. How do you add CSS styling in HTML?


● Inline CSS: It is used when less 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:

● Internal Style Sheet: It is used when a single HTML document has a unique style, and
several elements must be styled to follow the format. Internal styles sheet is added in the
head section of an HTML page by using the <style> tag:
23. How do you add JavaScript to an HTML webpage?
JavaScript is used to make HTML web pages more interactive and user-friendly. It is a scripting
language that allows you to interact with some aspects of the page based on user input. As with
CSS, there are three significant ways of including JavaScript:
JS file also be connected in head tag.
● 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:

● 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.
● External JavaScript file:
You can also import the JavaScript code from a separate file and keep your HTML code clutter-
free. This is especially useful if a large amount of scripting is added to an HTML webpage.

24. What is the ‘class' attribute in HTML?


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.

25. 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.

26. 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.

27. What is the difference between HTML and HTML5?


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.
28. What is the role of the <head> tag in HTML?
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.

29. What is the role of the <meta> tag in HTML?


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.

30. What is the difference between an absolute and relative URL?


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).

31. What is the role of the title attribute in HTML?


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.

32. What is a form in HTML?


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.

33. 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.
34. What is the role of the action attribute in HTML forms?
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.

35. What is the role of the method attribute in HTML forms?


The method attribute specifies the HTTP method for submitting the form data. The two most
common methods are GET and POST. GET retrieves data from the server, while POST sends
data to the server.

36. In how many ways can you display HTML elements?


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.

37. 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.

38. 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.

39. 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.
40. 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.

41. How to handle events in HTML?


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.

42. 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 mobile device support. It also includes new
APIs for working with web applications, such as the Geolocation API and the Canvas API.

43.

You might also like