Deep Dive of Html Conceptual Questions

Anatomy of Html ~

Below are certain conceptual questions I've gone through, that might can help others too.
Give a Read
🎃

Are the HTML tags and elements the same thing?
No. HTML elements are defined by a starting tag and may contain some content and a closing tag. For example, <h1>Heading 1</h1> is an HTML element but just <h1> is a starting tag and </h1> is a closing tag.

What are tags and attributes in HTML?

Tags are the primary component of the HTML that defines how the content will be structured/ formatted, whereas Attributes are used along with the HTML tags to define the characteristics of the element. For example,
<p align=”centre”>Center this paragraph</p>, in this the ‘align’ is the attribute using which we will align the paragraph to show in the centre of the view.

What are void elements in HTML?

HTML elements which do not have closing tags or do not need to be closed are Void elements. For Example <br />, <img />, <hr />, etc.

What is the advantage of collapsing white space?

In HTML, a blank sequence of whitespace characters is treated as a single space character, Because the browser collapses multiple spaces into a single space character and this helps a developer to indent lines of text without worrying about multiple spaces and maintain readability and understandability of HTML codes.

What is the ‘class’ attribute in HTML?

The class attribute is used to specify the class name for an HTML element. Multiple elements in HTML can have the same class value. Also, it is mainly used to associate the styles written in the stylesheet with the HTML elements

Define multipart form data.

Multipart form data is one of the values of the type attribute. It is used to send the file data to the server side for processing. The other valid values of the type attribute are text/plain and application/x-www-form-urlencoded.

Describe the HTML layout structure.
Every web page has different components to display the intended content and a specific UI. But still, there are a few things which are templated and globally accepted ways to structure the web page, such as:<header>: Stores the starting information about the web page.<footer>: Represents the last section of the page.<nav>: The navigation menu of the HTML page.<article>: It is a set of information.<section>: It is used inside the article block to define the basic structure of a page.<aside>: Sidebar content of the page.

How to optimize website asset loading?

To optimize website load time we need to optimize its asset loading and for that:
CDN hosting - A CDN or content delivery network is geographically distributed servers to help reduce latency.

File compression - This is a method that helps to reduce the size of an asset to reduce the data transfer.

File concatenation - This reduces the number of HTTP calls.
Minify scripts - This reduces the overall file size of js and CSS files
Parallel downloads - Hosting assets in multiple subdomains can help to bypass the download limit of 6 assets per domain of all modern browsers. This can be configured but most general users never modify these settings.

Lazy Loading - Instead of loading all the assets at once, the non-critical assets can be loaded on a need basis.

What are the different kinds of Doctypes available?

Three kinds of Doctypes: Strict Doctype, Transitional Doctype Frameset Doctype.

What is the difference between <strong>, <b> tags and <em>, <i> tags?

The effect on a normal webpage of the tags <strong>, <b> and <em>, <i> is the same. <b> and <i> tags stand for bold and italic. These two tags only apply font styling and bold tag <b>, which just adds more ink to the text, these tags don't say anything about the text. Whereas, <strong> and <em> tags represent that the span of text is of strong importance or more importance and emphatic stress respectively than the rest of the text. These tags have semantic meaning.

What is the significance of <head> and <body> tag in HTML?

<head> tag provides the information about the document. It should always be enclosed in the <html> tag. This tag contains the metadata about the webpage and the tags which are enclosed by head tag like <link>, <meta>, <style>, <script>, etc. are not displayed on the web page. Also, there can be only 1 <head> tag in the entire Html document and will always be before the <body> tag.<body> tag defines the body of the HTML document. It should always be enclosed in the <html> tag. All the contents which need to be displayed on the web page like images, text, audio, video, and contents, using elements like <p>, <img>, <audio>, <heading>, <video>, <div>, etc. will always be enclosed by the <body> tag. Also, there can be only 1 body element in an HTML document and will always be after the <head> tag.

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

If the scripts contain some event-triggered functions or jquery library then we should use them in the head section. If the script writes the content on the page or is not inside a function then it should be placed inside the body section at the bottom. In short, follow below three points:
Place library scripts or event scripts in the head section.
Place normal scripts that do not write anything on the page, in the head section until any performance issue.
Place scripts render something on the web page at the bottom of the body section.

Did you find this article valuable?

Support Siddharth verma by becoming a sponsor. Any amount is appreciated!