HTML Deck 4 Flashcards

1
Q

What are the different types of lists in HTML?

A

A list is a record of short pieces of related information used to display the data or any information on web pages in the ordered or unordered form. HTML offers 3 ways for specifying lists of information. All lists must contain one or more list elements. The types of lists that can be used in HTML are:

Unordered List: It will list the items using plain bullets.
Ordered List: It will use different schemes of numbers to list your items.
Definition List: It arranges your items in the same way as they are arranged in a dictionary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The Basic Skeleton of HTML:

A

<html>
<head>
<title> Interviewbit </title>
</head>
<body>
..........................
....Body contents here....
..........................
</body>
</html>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Root Element in HTML

A

<html>...</html>

: The root (top-level element) of an HTML page is represented by the <html> element or the <html> tag. This element must be the ancestor of all other elements. The structure of any HTML file showing the usage of the <html> element is shown below:
<!DOCTYPE html>

<html>
<head>...</head>
<body>...</body>
</html>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

HTML Meta Tag

A

<head>...</head>

: Machine-readable information (metadata) about the document, such as its title, scripts, and style sheets, is contained in the HTML <head> element. The <head> element This is used for setting the title and various other information that is not displayed.

<link></link>

…</link>: The HTML External Resource Link <link></link> element establishes a connection between the current content and an external resource. This element is most typically used to connect to stylesheets, but it can also be used to create site icons (both “favicon” style icons and icons for the home screen and apps on mobile devices).

<meta></meta>

: Metadata that cannot be represented by other HTML meta related elements such as <base></base>, <link></link>,

, <style>, or <title> is expressed by the HTML <meta></meta> element.</title></style>

<style>

...
</style>

: The HTML <style> element specifies the style of a document or a section of a document.</style>

<title>...</title>

: The HTML Title element <title> specifies the document title that appears in the title bar or tab of a browser. This is what is bookmarked when we bookmark pages.</title>

<!DOCTYPE html>

<html>
<head>
<meta></meta>
<title> HTML Cheatsheet </title>
<link></link>
<style>

        h1 {colour:green;}
        p {colour:yellow;}
      
</style>
</head>
</html>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

HTML Elements: Adding Scripting

A
<script>
…
</script>

: The HTML

 element is used to embed or refer to executable code; for example, JavaScript code is generally embedded or referred to using this element. An example which shows the usage of the 
 element is given below:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are void elements in HTML?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why do we use a style sheet in HTML?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is semantic HTML?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is SVG in HTML?

A

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>

<circle></circle>

</svg>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you add CSS styling in HTML?

A

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></link> tag:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What hierarchy do the style sheets follow?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you add JavaScript to an HTML webpage?

A

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:

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 there is a large amount of scripting added to an HTML webpage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the ‘class’ attribute in HTML?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between the ‘id’ and ‘class’ attributes of HTML elements?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between HTML and XHTML?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the role of the <head> tag in HTML?

A

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.

17
Q

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

A

The <meta></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.

18
Q

What is the difference between an absolute and relative URL?

A

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

19
Q

What is the role of the title attribute in HTML?

A

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.

20
Q

What is a form in HTML?

A

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.

21
Q

What is the role of the action attribute in HTML forms?

A

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.

22
Q

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

A

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

23
Q

What is the difference between “display: none” and “visibility: hidden” when used as attributes to the HTML element?

A

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.

24
Q

What is the difference between link tag <link></link> and anchor tag <a></a>

A

The <link></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.</a>

25
Q

When to use scripts in the head and when to use scripts in the body?

A

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.

26
Q

What are forms, and how to create forms in HTML?

A

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.

27
Q

How to handle events in HTML?

A

Events can be handled using JavaScript, which can be included in the HTML document using the

 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.
28
Q

What are some advantages of HTML5 over its previous versions?

A

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.

As you get prepared for your job interview, we hope that these HTML Interview Questions have provided more insight into what types of questions you are likely to come across.

29
Q

What is SVG in HTML?

A

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.

30
Q

What is the difference between href and src?

A

An “a href link” (or “href link”) is HTML code that uses an <a> tag and href attribute to create a clickable hyperlink. There are other types of HTML links (e.g., the <link></link> tag). And other ways to create hyperlinks (e.g., with JavaScript).</a>

CSS uses href because it uses the <link></link> tag that means it links to something. HREF stands for Hypertext Reference. From the name we can attribute that it is referencing the file into HTML. It is linking the reference to it. While src just stands for source, which just embed the file into the HTML.

This also means that src can give the script 3 modes to run in, asynchronously, defer, and just runs where the script tag exist. This means we can run the script asynchronously with the HTML, or we can run the script after the page is loaded or just run it when the script tag is seen. This means the script tag can pause the parsing process of the HTML and wait until the Javascript is run or vice versa.

While the href tag tells the HTML parser that it’s just a reference link and it won’t stop the parser to parse the HTML while also parsing the CSS with the HTML. It might not render instantly, but it’s parsed and ready to go.