HTML Questions Flashcards

1
Q

What does a doctype do?

A

The doctype, which appears at the very beginning of your markup, defines what type of markup you will be using.

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

How do you serve a page with content in multiple languages?

A

Begin by setting the language attribute in the <html> tag of your web page. This attribute informs search engines and browsers about the primary language of your content, such as lang=”en”.

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

What kind of things must you be wary of when designing or developing for multilingual sites?

A

When developing multilingual sites in HTML, consider character encoding, language markup, text direction, language-specific formatting, language switching, SEO, language-specific URLs, CMS support, and thorough localization testing for a seamless and effective user experience.

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

What are data- attributes good for?

A

Allow us to store extra information on standard, semantic HTML elements without other hacks such as non-standard attributes, or extra properties on DOM. Provides a flexible and extensible way to enrich your HTML with custom data, enabling easier interaction, styling, and manipulation of elements using JavaScript and CSS.

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

Data attributes and Custom Data Storage

A

Data attributes allow you to attach specific data values to HTML elements, providing a convenient way to store information related to a particular element.

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

Data Attributes and JavaScript Interaction

A

Data attributes can be easily accessed and manipulated using JavaScript. They provide a simple way to pass data between HTML and JavaScript code, making it easier to enhance interactivity and dynamic behavior.

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

CSS Styling and Selectors in regards to data attributes

A

You can target elements based on their data attribute values in CSS. This allows for more precise styling and targeting of specific elements based on custom data associated with them.

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

Data Attributes and Markup Semantics:

A

By using data attributes, you can maintain the integrity of your HTML markup while adding custom data. This ensures that your HTML remains valid and adheres to standard semantics.

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

Frameworks and Libraries in regards to data attributes

A

Many JavaScript frameworks and libraries, such as jQuery and React, provide built-in support for data attributes. They offer convenient methods and APIs to access and manipulate data attributes, simplifying development and integration.

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

Consider HTML5 as an open web platform. What are the building blocks of HTML5?

A

(tags, elements and attributes.)

  • Semantic elements such as the header, main, section, footer, etc.
  • Introduced new attributes for the form’s tag.
  • The local storage of data that allows webpages to function more efficiently offline.
  • Embedding multimedia is possible without third-party plugins.
  • Canvas that offers a much greater range of presentation options.
  • Document Object Model (DOM) and APIs.
  • Support for mathematical formulas and SVG files.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe the difference between a cookie, sessionStorage and localStorage.

A

Local storage is useful for storing data that the user will need to access later, such as offline data. Session storage is a great way to improve the performance of your web applications (cookie side). Cookies are a good choice for storing data that should not be persisted for a long time, such as session IDs (client side)

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

</script>
A

When the browser encounters a

 tag, it pauses parsing the HTML, fetches and executes the JavaScript code before continuing to parse the rest of the HTML. It blocks the rendering of the page until the script has been fetched and executed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
<script>

</script>
A

The async attribute tells the browser to fetch the script asynchronously while continuing to parse the HTML. Once the script is fetched, it is executed as soon as possible, even if the HTML parsing is not complete. This allows the script to be executed independently of the HTML parsing, potentially improving page load performance. Multiple

 tags can load and execute scripts concurrently.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
<script>

</script>
A

The defer attribute also allows the browser to fetch the script asynchronously. However, the defer attribute ensures that the script is executed only after the HTML parsing is complete, just before the DOMContentLoaded event is fired. This preserves the order of execution of scripts as they appear in the HTML document.

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

Why is it generally a good idea to position CSS <link></link>s between <head></head> and JS

s just before </body>? Do you know any exceptions?
A

In a nutshell, such a placement of CSS <link></link> s and JavaScript

 s allows for faster rendering of the page and better overall performance.
  • The main reason as to why JS files are linked at the bottom of the body is because whenever a browser encounters any JS, it parses it and executes that on the spot. Hence if it was to be added at the top, it would make the page rendering slow and thus it would take more time for page load. Moreover since the DOM won’t be rendered fully, JS won’t be able to manipulate the elements.
  • CSS files are linked in the head because they get applied regardless of DOM already rendered or not. Hence the webpage looks elegant as soon as the page loads. However just like JS you can link the CSS at the end which would mean that the webpage first loads with just plain HTML and then the CSS is applied to it. This shift is clearly visible to the user and moreover an important thing to remember is that the page would load with bare minimum HTML and if the user has slow Internet connection, the CSS load would take considerable amount of time, which means that the webpage shows just the HTML meanwhile. This might make the user close the website without waiting for it to load fully.
  • However if you use Jquery, that won’t be an issue since it would execute only after the document is ready. But since in any case, the browser would parse it, it would slow the page load.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is progressive rendering?

A

A technique to improve the performance of the web page by rendering the HTML, CSS, and JavaScript content of the web page in smaller chunks or whenever required.

17
Q

Why you would use a srcset attribute in an image tag? Explain the process the browser uses when evaluating the content of this attribute.

A

You would use this attribute when you want to serve different images to users depending on their device display width - serve higher quality images to devices with retina display enhances the user experience while serving lower resolution images to low-end devices increase performance and decrease data wastage (because serving a larger image will not have any visible difference)

18
Q

Have you used different HTML templating languages before?

A

Yes, Pug (formerly Jade), ERB, Slim, Handlebars, Jinja, Liquid, and EJS just to name a few. In my opinion, they are more or less the same and provide similar functionality of escaping content and helpful filters for manipulating the data to be displayed. Most templating engines will also allow you to inject your own filters in the event you need custom processing before display.

19
Q

What is the difference between canvas and svg?

A

SVG is a language for describing 2D graphics in XML. Canvas draws 2D graphics, on the fly (with a JavaScript). SVG is XML based, which means that every element is available within the SVG DOM.

20
Q

What are empty elements in HTML ?

A

The elements of HTML that cannot have some content like text or child element inside them. There is no need to specify the closing tag, and the opening tag should end with /> instead of >.

<br></br>, <hr>, and <img></img> are considered empty tags, void tags, or self-closing tags as they cannot contain other elements or content.

21
Q

Does HTML need a compiler?

A

All you need is a web browser and a text editor. There is no need to install compilers or interpreters.

22
Q

Which is the best HTML debugging tool?

A

Chrome DevTools

23
Q

Explain Semantic HTML.

A

Elements that clearly describe their meaning in a human- and machine-readable way.

24
Q

Explain the difference between <article> and <section> tag.

A

The section tag defines sections in a document, such as chapters, headers, footers, or any other sections of the document. The <article> tag: The article tag specifies independent, self-contained content.

25
Q

Explain Meta Viewport.

A

Without a viewport meta tag, mobile devices render pages at typical desktop screen widths and then scale the pages down, making them difficult to read. Setting the viewport meta tag lets you control the width and scaling of the viewport so that it’s sized correctly on all devices.

26
Q

How do you check for errors in HTML?

A

Run the code.

27
Q

How are active links different from normal links?

A

Active Links shows that the browser is in the process to load a new resource. A normal link is an unvisited link.

28
Q

When is it appropriate to use frames?

A

HTML frames are used to divide your browser window into multiple sections where each section can load a separate HTML document. A collection of frames in the browser window is known as a frameset.

29
Q

Is <!DOCTYPE html> tag a HTML tag?

A

The declaration is not an HTML tag. It is an “information” to the browser about what document type to expect.

30
Q

What are the two types of Web Storage in HTML5?

A
  • window.localStorage - stores data with no expiration date.
  • window.sessionStorage - stores data for one session (data is lost when the browser tab is closed)
31
Q

What is the difference between XHTML, HTML4 and HTML5?

A

XHTML is a combination of HTML and XML, while HTML5 is a version of HTML. XHTML has its own parsing requirements, while HTML does not have any specific requirements and uses its own.