HTML & CSS II Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How does CSS3 differ from CSS?

A

CSS3 is the most recent version of CSS. It has introduced a bunch of new tags to give a better user experience. Some of the features are rounded corners, animation, custom layouts, and media queries.

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

How does CSS3 support responsive web designing?

A

CSS3 has come up with a media query feature. It supports RWD (Responsive Web Design) and does help in making a website responsive.

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

What is a CSS selector?

A

A CSS selector is an expression following the CSS rules and is used to select the element we want to style. And, CSS selector syntax means how we write or use those selectors in the CSS editor.

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

What are the different types of CSS?

A

Below are the different types of CSS.

Embedded – It adds the CSS styles using the <style> attribute; Embedded CSS refers to the use of a <style> element within the <head> section of an HTML document.</style></style>

Inline – It adds CSS to the HTML elements; You use the style attribute within an HTML tag

Linked/External – It adds an external CSS file to the HTML document.

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

What is an ID selector?

A

The ID selector uses the “ID” attribute of the target HTML element to select it. The constraint to work is that the ID should be unique within a page so that the selector can point it out correctly.

To build an ID selector expression, start with a hash (#) character, followed by the id of the element.

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

What is Grouping in CSS3?

A

Grouping makes it possible to apply the same style to multiple HTML elements (Classes/Tag/ID) within a single declaration. It happens by specifying all the selectors separated by commas.

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

What are Child Selectors in CSS?

A

A child selector looks up for the child of some element. To form a child selector, we need two or more selectors separated by the “greater than” symbol.

Let’s take an example. We have a <ul> tag inside a paragraph. Here, <ul> is the child of the paragraph element. So, to apply the CSS styles, we can use the following syntax.

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

What is Webkit in CSS3? And why is it used?

A

Webkit is a core software component that is responsible for rendering HTML and CSS in browsers like Safari and Chrome. There are other similar rendering engines like Gecko for Mozilla, Presto for Opera, and Edge for IE.

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

What is CSS Box Model and what are its components?

A

The CSS Box Model represents a box that confines every HTML element such as a text box, a menu, or a button. It has primarily four core components.

Margin – It refers to the topmost layer of the box.
Border – The padding and content options work around the Border. Changing the background color can also affect the Border.
Padding – It defines spacing around the box.
Content – It represents the actual content to be shown.

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

What are media queries in CSS3 and why do you use them?

A

Media queries are one of the latest features of CSS3 used to define responsive styles for devices of different shapes and sizes.

They are powerful CSS tool that makes it easy to create a responsive design for tablets, desktop, and mobile devices. They can help to adjust the Height, Width, Viewport, Orientation, and Resolution

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

What are Pseudo-Classes in CSS?

A

A Pseudo-Class is a CSS technique to set the style when the element changes its state.

For example

Edit the style upon mouse hover event.
Set the style when an element gets focused.
Apply different styles for visited/unvisited links.

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

What is the use of float property in CSS?

A

With the help of the float property, we can control the position and layout of elements on a web page.

For example, it can define the placement of a <div> either to the right or left side.

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

Which property do you use to modify the face of a font in CSS?

A

First of all, please note that both the terms <@font-face> and <font-family> refer to changing the font of an HTML element. However, there is a slight difference between the two.</font-family>

  1. The <@font-face> is a CSS rule that facilitates the use of custom fonts on a web page.
  2. The <font-family> is a CSS property that specifies the font for a web element.</font-family>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is Z-index and how does it work?

A

The z-index is a CSS property that defines the stack order of web elements. Higher-order elements will appear before any lower-order element.

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

What does float do?

A

float pushes an element to the sides of a page with text wrapped around it. you can create entire page or a smaller area by using float. if size of a floated element changes, text around it will re-flow to accommodate the changes. You can have float left, right, none or inherit.

if you set, ‘float: left;’ for an image, it will move to the left until the margin, padding or border of another block-level element is reached. The normal flow will wrap around on the right side.

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

How can you clear sides of a floating element?

A

If you clear a slide of an element, floating elements will not be accepted on that side. With ‘clear’ set to ‘left’, an element will be moved below any floating element on the left side. clear is used to stop wrap of an element around a floating element.

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

Does css properties are case sensitive?

A

no

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

Why css selectors mixed up with cases don’t apply the styles?

A

html ID and classes are case sensitive.

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

Does margin-top or margin-bottom has effect on inline element?
Does padding-top or padding-bottom has effect on inline element?

A

No

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

Does padding-left or padding-right or margin-left or margin-right has effect on inline element?

A

yes

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

Which one would you prefer among px, em % or pt and why?

A

px gives fine grained control and maintains alignment because 1 px or multiple of 1 px is guaranteed to look sharp. px is not cascade, this means if parent font-size is 20px and child 16px. child would be 16px.

em maintains relative size. you can have responsive fonts. em is the width of the letter ‘m’ in the selected typeface. However, this concept is tricky. 1em is equal to the current font-size of the element or the browser default. if u sent font-size to 16px then 1em = 16px. The common practice is to set default body font-size to 62.5% (equal to 10px). em is cascade

% sets font-size relative to the font size of the body. Hence, you have to set font-size of the body to a reasonable size. this is easy to use and does cascade. for example, if parent font-size is 20px and child font-size is 50%. child would be 10px.

pt(points) are traditionally used in print. 1pt = 1/72 inch and it is fixed-size unit.

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

How absolute, relative, fixed and static position differ?

A

absolute, place an element exactly where you want to place it. absolute position is actually set relative to the element’s parent. if no parent available then relatively place to the page itself.

relative, is position an element relative to itself (from where the element would be placed, if u don’t apply relative positioning). for example, if u set position relative to an element and set top: 10px, it will move 10px down from where it would be normally.

fixed, element is positioned relative to viewport or the browser window itself. viewport doesn’t changed if u scroll and hence fixed element will stay right in the same position.

static, element will be positioned based on the normal flow of the document. usually, u will use position static to remove other position might be applied to an element.

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

What are the differences between visibility hidden and display none?

A

display:** none removes the element from the normal layout flow and allow other elements to fill in**.

visibility: hidden tag is rendered, it takes space in the normal flow but doesn’t show it.

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

What are the differences between inline, block and inline-block?

A

inline, elements do not break the flow. think of span it fits in the line. Important points about inline elements, margin/ padding will push other elements horizontally not vertically. Moreover, inline elements ignores height and width.

block, breaks the flow and dont sits inline. they are usually container like div, section, ul and also text p, h1, etc.

inline-block, will be similar to inline and will go with the flow of the page. Only differences is this this will take height and width.

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

What are the properties related to box model?

A

Technically, height, width, padding and border are part of box model and margin is related to it.

Everything in a web page is a box where you can control size, position, background, etc. Each box/ content area is optionally surrounded by padding, border and margin. When you set height and width of an element, you set content height and width.

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

What are the some pseudo classed u have used?

A

pseudo class tells you specific state of an element. allow to style element dynamically. The most popular one is :hover. Besides i have used :visited, :focus, :nth-child, nth-of-type, :link, etc.

pseudo classes is better if you don’t want to mess up with javaScript however, pseudo-classes is slow to process and apply rules.

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

How do you align a p center-center inside a div?

A

text-align: center will do the horizontal alignment but **vertical-align: **middle will not work here. there are couple of different ways to solve this problem and one of them are positioning. You make the parent as relative position and child as absolute positioning.

And then define all position parameter as sero and width 50% and height 30% (sounds messy look at the example and read ref)

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

How can you load css resources conditionally?

A

@import allows you to load/ import stylesheet by using a path (uri) representing the location of the file. You can define one or more media by comma separation for which you want to load the stylesheet. If browser dont support the media stylesheet will not be loaded.

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

Why would you use sprites?

A

When you have multiple images/ icons, browser makes separate call to the server for each one of them.

sprite is a technique to combine all/ some of them (usually similar one in terms of type of image. For example, you will put jpg in one sprite) in one image.

To display the icon you set height, width and background position.

popular libraries like bootstrap use this technique. If you repeat the image. want to scale you have to be careful with sprite.

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

What is specificity? How do u calculate specificity?

A

is a process of determining which css rule will be applied to an element. it actually determines which rules will take precedence.

inline style usually wins then ID then class value (or pseudo-class or attribute selector), universal selector (*) has no specificity.

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

What is shadow DOM?

A

encapsulate part of a DOM.

hide subtree. you can have same ID in different shadow DOM. Polymers uses it. This way your DOM becomes reusable.

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

What do you know about transition?

A

transition allows to add an effect while changing from one style to another. You can set the which property you want to transition, duration, how you want to transit (linear, ease, ease-in, ease-out, cubic-bezier) and delay when transition will start. you can transition more than one property by comma separation

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

What are the different css filter you can use?

A

css filter allows u to render DOM element, image, or video. u can choose from: grayscale, blur, opacity, brightness, contrast.

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

What are the reasons to use preprocessor?

A

you write css in high level with some** special syntax (declaring variable, nested syntax, mathematical operations, etc.)** and that is compiled to css. Preprocessor helps you to speed up develop, maintain, ensure best practices and also confirms concatenation, compression, etc.

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

What is HTML?

A

HTML stands for HyperText Markup Language. It is a standard text formatting language used for developing web pages released in 1993. HTML is a language that is interpreted by the browser and it tells the browser what to display and how to display.

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

What are tags and attributes in HTML?

A

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=” center”>Interview questions</p>, in this the ‘align’ is the attribute using which we will align the paragraph to show in the center of the view.

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

Can we display a web page inside a web page or Is nesting of webpages possible?

A

Yes, we can display a web page inside another HTML web page. HTML provides a tag <iframe> using which we can achieve this functionality.

<iframe src=”url of the web page to embed” />

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

What are void elements in HTML?

A

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

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

What is the advantage of collapsing white space?

A

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

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

What are HTML Entities?

A

In HTML some characters are reserved like ‘<’, ‘>’, ‘/’, etc. To use these characters in our webpage we need to use the character entities called HTML Entities. Below are a few mapping between the reserved character and its respective entity character to be used.

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

What are different types of lists in HTML?

A

<ul> unordered list
<ol> ordered list
</ol></ul>

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

What is the ‘class’ attribute in HTML?

A

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.

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

How to optimize website assets loading?

A

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.

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

What are the various formatting tags in HTML?

A

HTML has various formatting tags:

<b> - makes text bold
<i> - makes text italic
<em> - makes text italic but with added semantics importance
<big> - increases the font size of the text by one unit
<small> - decreases the font size of the text by one unit
- makes the text a subscript
- makes the text a superscript
<del> - displays as strike out text
<strong> - marks the text as important
<mark> - highlights the text
<ins> - displays as added text</ins></mark></strong></del>
</small></big></em></i></b>

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

What are the different kinds of Doctypes available?

A

Strict Doctype
Transitional Doctype
Frameset Doctype

46
Q

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

A

The effect on a normal webpage of the tags <strong>, <b> and <em>, <i> is the same. <b> and <i> tags stands for bold and italic. These two tags only apply font styling and bold tag <b>, just adds more ink to the text, these tags don’t say anything about the text.</b></i></b></i></em></b></strong>

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.</em></strong>

47
Q

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

A

<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></link>, <meta></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 needs to be displayed on the web page like images, text, audio, video, 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
</style></html></head>
48
Q

Are the HTML tags and elements the same thing?

A

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

49
Q

How is Cell Padding different from Cell Spacing?

A

Cell Spacing is the space or gap between two consecutive cells. Whereas, Cell Padding is the space or gap between the text/ content of the cell and the edge/ border of the cell. Please refer to the above figure example to find the difference.

50
Q

How can we club two or more rows or columns into a single row or column in an HTML table?

A

HTML provides two table attributes “rowspan” and “colspan” to make a cell span to multiple rows and columns respectively.

51
Q

Is it possible to change an inline element into a block level element?

A

Yes, it is possible using the “display” property with its value as “block”, to change the inline element into a block-level element.

52
Q

In how many ways can we position an HTML element? Or what are the permissible values of the position attribute?

A

static: Default value. Here the element is positioned according to the normal flow of the document.

absolute: Here the element is positioned relative to its parent element. The final position is determined by the values of left, right, top, bottom.

fixed: This is similar to absolute except here the elements are positioned relative to the <html> element.

relative: Here the element is positioned according to the normal flow of the document and positioned relative to its original/ normal position.

initial: This resets the property to its default value.

inherit: Here the element inherits or takes the property of its parent

53
Q

In how many ways you can display HTML elements?

A

inline: Using this we can display any block-level element as an inline element. The height and width attribute values of the element will not affect.

block: using this, we can display any inline element as a block-level element.

inline-block: This property is similar to inline, except by using the display as inline-block, we can actually format the element using height and width values.

flex: It displays the container and element as a flexible structure. It follows flexbox property.

inline-flex: It displays the flex container as an inline element while its content follows the flexbox properties.

grid: It displays the HTML elements as a grid container.

none: Using this property we can hide the HTML element.

54
Q

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

A

When we use the attribute “visibility: hidden” for an HTML element then that element will be hidden from the webpage but** still takes up space**. Whereas, if we use the “display: none” attribute for an HTML element then the element will be hidden, and also it won’t take up any space on the webpage

55
Q

How to specify the link in HTML and explain the target attribute?

A

HTML provides a hyperlink - <a> tag to specify the links in a webpage. The ‘href’ attribute is used to specify the link and the ‘target’ attribute is used to specify, where do we want to open the linked document. The ‘target’ attribute can have the following values:</a>

_self: This is a default value. It opens the document in the same window or tab as it was clicked.
_blank: It opens the document in a new window or tab.
_parent: It opens the document in a parent frame.
_top: It opens the document in a full-body window

56
Q

In how many ways can we specify the CSS styles for the HTML element?

A

There are three ways in which we can specify the styles for HTML elements:

Inline: Here we use the ‘style’ attribute inside the HTML element.

Internal: Here we use the <style> tag inside the <head> tag. To apply the style we bind the elements using ‘id’ or ‘class’ attributes.</style>

External: Here we use the <link></link> tag inside <head> tag to reference the CSS file into our HTML code. Again the binding between elements and styles is done using ‘id’ or ‘class’ attributes.

57
Q

Difference between link tag <link></link> and anchor tag <a>?</a>

A

The anchor tag** <a> is used to create a hyperlink to another webpage or to a certain part of the webpage and these links are clickable, whereas, link tag <link></link> defines a link between a document and an external resource and these are not clickable.**</a>

58
Q

How to include javascript code in HTML?

A

HTML provides a

 tag using which we can run the javascript code and make our HTML page more dynamic.
59
Q

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

A

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 there is any performance issue.

Place scripts that render something on the web page at the bottom of the body section

60
Q

What are forms and how to create forms in HTML?

A

The HTML form is used to collect the user inputs. HTML provides a <form> tag to create forms. To take input from the user we use the <input></input> tag inside the form so that all collected user data can be sent to the server for processing. There are different input types like ‘button’, ‘checkbox’, ‘number’, ‘text’, ‘password’, ‘submit’ etc.

61
Q

How to handle events in HTML?

A

HTML allows event trigger actions in browsers using javascript or JQuery. There are a lot of events like ‘onclick’, ‘ondrag’, ‘onchange’, etc.

62
Q

What is new about the relationship between the <header> and <h1> tags in HTML5?

A

As HTML5 was all about better semantics and arrangements of the tags and elements, the <header> tag specifies the header section of the webpage. Unlike in previous version there was one <h1> element for the entire webpage, now this is the header for one section such as <article> or <section>. According to the HTML5 specification, each <header> element must at least have one <h1> tag

63
Q

Inline elements

A

Inline elements just take up the space that is absolutely necessary for the content and does not start from a new line.
Example:- <span>, <a>, <strong>, <img></img>, <button>, <em>, <select>, <abbr>, <label>, , <cite>, <abbr>,

, <label>, <i>, <input></input>, <output>, <q>, etc.</q></output></i></label>
</abbr></cite></label></abbr></select></em></button></strong></a></span>

64
Q

Block

A

Block elements start on a new line and consume the full width of the page available.
Example:- <div>, <p>, <header>, <footer>, <h1>…<h6>, <form>, <table>, <canvas>, <video>, <blockquote>, <pre>, <ul>, <ol>, <figcaption>, <figure>, <hr>, <article>, <section>, etc.</figure></video></canvas>

65
Q

What is the difference between <figure> tag and <img></img> tag?</figure>

A

The <figure> tag specifies the self-contained content, like diagrams, images, code snippets, etc. <figure> tag is used to semantically organize the contents of an image like image, image caption, etc., whereas the <img></img> tag is used to embed the picture in the HTML5 document</figure></figure>

66
Q

How to specify the metadata in HTML5?

A

To specify we can use <meta></meta> tag which is a void tag,i.e., it does not have a closing tag. Some of the attributes used with meta tags are name, content, http-equiv, etc. The below image tells how to specify the metadata.

67
Q

Is the <datalist> tag and <select> tag same?</select></datalist>

A

No. The <datalist> tag and <select> tag are different. In the case of <select> tag a user will have to choose from a list of options, whereas <datalist> when used along with the <input></input> tag provides a suggestion that the user selects one of the options given or can enter some entirely different value.</datalist></select></select></datalist>

68
Q

What are Semantic Elements?

A

Semantic elements are those which describe the particular meaning to the browser and the developer. Elements like <form>, <table>, <article>, <figure>, etc., are semantic elements.</figure>

69
Q

What is the difference between <meter> tag and <progress> tag?</progress></meter>

A

<progress> tag should be used when we want to show the completion progress of a task, whereas if we just want a scalar measurement within a known range or fraction value. Also, we can specify multiple extra attributes for <meter> tags like ‘form’, ‘low’, ‘high’, ‘min’, etc.
</meter></progress>

70
Q

Difference between SVG and Canvas HTML5 element?

A

SVG:
SVG is a vector based i.e., composed of shapes.
SVG works better with a larger surface.
SVG can be modified using CSS and scripts.
SVG is highly scalable. So we can print at high quality with high resolution.

Canvas:
It is Raster based i.e., composed of pixels.
Canvas works better with a smaller surface.
Canvas can only be modified using scripts.
It is less scalable.

71
Q

What type of audio files can be played using HTML5?

A

HTML5 supports the following three types of audio file formats:

Mp3
WAV
Ogg

72
Q

What are the significant goals of the HTML5 specification?

A

These were the target area of the HTML5 specs:

Introduction of new element tags to better structure the web page such as <header> tag.

Forming a standard in cross-browser behavior and support for different devices and platforms

Backward compatible with the older version HTML web pages

Introduction of basic interactive elements without the dependency of plugins such as <video> tag instead of the flash plugin</video>

73
Q

Explain the concept of web storage in HTML5.

A

This web storage helps in storing some of the static data in the local storage of the browser so that we do not need to fetch it from the server every time we need it. There is a size limit based on different browsers. This helps in decreasing the load time and a smooth user experience. There are two types of web storage that are used to store data locally in HTML5:

Local Storage - This helps in storing data that will be retained even though the user reopens the browser. It is stored for each webapp on different browsers.

**Session Storage **- This is used for one session only. After the user closes the browser this gets deleted

74
Q

Which tag is used for representing the result of a calculation? Explain its attributes.

A

The <output> tag is used for representing the result of a calculation. It has the following attributes:</output>

for - It defines the relationship between the elements used in calculation and result.
form - This is used to define the form the output element belongs to.
name - The name of the output element.

75
Q

Canvas

A

It is like drawing on a whitepaper or a blank webpage. We can add different graphic designs on web pages with available methods for drawing various geometrical shapes.

76
Q

What are the server-sent events in HTML5?

A

The events pushed from the webserver to the browsers are called server-sent events. DOM elements can be continuously updated using these events. This has a major advantage over straight-up polling. In polling, there is a lot of overhead since every time it is establishing an HTTP connection and tearing it down whereas, in server-sent events, there is one long-lived HTTP connection. To use a server-sent event, <eventsource> element is used. The src attribute of this element specifies the URL from which sends a data stream having the events</eventsource>

77
Q

What are Web Workers?

A

These are added to bring parallelism and async capability. It runs in the background to do the computationally expensive tasks without yielding to make the page responsive. It is achieved by starting a separate thread for such tasks. These are not meant to perform UI operations. There are three types of web workers:

Dedicated Workers - These are workers that are utilized by a single script.

Shared Workers -These are workers that are utilized by multiple scripts running in different windows, IFrames, etc.

Service Workers - These act as proxy servers between web applications, the browser, and the network. Mostly used for push notifications and sync APIs.

78
Q

What is a manifest file in HTML5?

A

The manifest file is used to list down resources that can be cached. Browsers use this information to make the web page load faster than the first time. There are 3 sections in the manifest file

CACHE Manifest - Files needs to be cached

Network - File never to be cached, always need a network connection.

Fallback - Fallback files in case a page is inaccessible

79
Q

What is the Geolocation API in HTML5?

A

Geolocation API is used to share the physical location of the client with websites. This helps in serving locale-based content and a unique experience to the user, based on their location. This works with a new property of the global navigator object and most of the modern browsers support this.

80
Q

Explain Web Components and it’s usage.

A

These are used to create reusable custom elements which are very difficult in traditional HTML. It consists of three technologies:

Custom elements - These are JavaScript APIs that help in defining custom elements and their behavior.

Shadow DOM - These are JavaScript APIs that attach an encapsulated shadow DOM tree to an element to keep the element’s features private and unaffected by other parts.

81
Q

What are some of the advantages of HTML5 over its previous versions?

A

Some advantages of HTML5 are:-

It has Multimedia Support.
It has the capabilities to store offline data using SQL databases and application cache.
Javascript can be run in the background.
HTML5 also allows users to draw various shapes like rectangles, circles, triangles, etc.

82
Q

What are HTML Attributes?

A

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

83
Q

What is a marquee in HTML?

A

Marquee is used for scrolling text on a web page. It automatically scrolls the image or text up, down, left, or right. You must use </marquee> tags to apply for a marquee.

84
Q

How do you separate a section of text in HTML?

A

We separate a section of text in HTML using the below tags:

<br></br> tag – It separates the line of text. It breaks the current line and shifts the flow of the text to a new line.

<p> tag–This tag is used to write a paragraph of text.

<blockquote> tag–This tag defines large quoted sections.
</blockquote></p>

85
Q

Define the list types in HTML.

A

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.

86
Q

Differentiate between an Ordered list and an Unordered list.

A

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.

87
Q

What is an element in HTML?

A

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.

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

89
Q

What is the advantage of collapsing white space?

A

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.

90
Q

What are HTML Entities?

A

Reserved characters in HTML must be replaced with entities:

< (less than) = <
> (greather than) = >

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.

91
Q

How do you display a table in an HTML webpage?

A

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:

<table>
It defines a table.

<tr>
It defines a row in a table.

<th>
It defines a header cell in a table.

<td>
It defines a cell in a table.

<caption>
It defines the table caption.

<tbody>
It is used to group the body content in a table.

<thead>
It is used to group the header content in a table.
</thead></tbody></caption></td></th></tr></table>

92
Q

What is semantic HTML?

A

Semantic HTML is a coding style that uses HTML markup to reinforce the semantics or meaning of the content.

For example, in semantic HTML, the <b> </b> tag is not used for bold statements as well, and the <i> </i> tag is not used for italics. Instead of these, we use <strong></strong> and <em></em> tags.

93
Q

What is the alt attribute in HTML?

A

The alt attribute displays text in place of an image whenever the image cannot be loaded due to technical issues.

94
Q

How do you add CSS styling in HTML?

A

There are three ways to include the CSS with 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></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:</style>

95
Q

What hierarchy do the style sheets follow?

A

If a single selector includes three different style definitions, the definition closest to the actual tag takes precedence. Inline style takes priority over embedded style sheets, which take priority over external style sheets.

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

97
Q

What is the difference between HTML and HTML5?

A

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.

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

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

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

101
Q

What is the role of the alt attribute in HTML?

A

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.

102
Q

What are the different types of form input fields in HTML?

A

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.

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

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

105
Q

What is new about the relationship between the <header> and <h1> tags in HTML5?

A

Details about the heading and title of the material on the webpage are contained in the <header> tag. This tag, which can appear as one or many tags on a single web page, contains the menu and logo for the website. It can contain other elements like <nav>, <hgroup>, <h1>, etc. While the <header> tag is often used to define the header of a page, it can also be used for other purposes, such as a footer or a sidebar.

A header tag called <h1> displays the document’s structure. Search engines use headings to index the content and structure of online pages. There are six headings in total, starting with <h1> and ending with <h6>. Any heading element, including h1, may be used multiple times within both the <header> and <body> sections, but it is generally recommended to use only one <h1> element per page.

106
Q

What are inline and block elements in HTML5?

A

Inline elements style or format particular content sections within block-level elements. For example, <span>, <a>, <strong>, and <em> take up only the appropriate width and do not begin on a new line. HTML Block components are used to organize a webpage’s major content. They usually begin on a new line and fill the entire container width, e.g., <div>, <p>, <h1> to <h6>, <ul>, etc.</em></strong></a></span>

107
Q

What is the difference between <figure> tag and <img></img> tag?</figure>

A

HTML <img></img> tag is used to add a picture in the webpage/website. In HTML5, you can <figure> tag to primarily group related content, such as an image and its caption or a code block and description. Examples of this type of material include diagrams, pictures, codes, and illustrations. Thus, In an HTML document, a picture is embedded using the image tag, while its content is logically organized using the figure tag.</figure>

108
Q

How to specify the metadata in HTML5?

A

Metadata is a <head> element component that helps online services, search engines, and browsers understand and display content. It aids in specifying the author, viewport settings, charset, title, and other page details. Although these tags are not visible on the website, they are significant for search engines and browsers as they organize and classify content.

109
Q

Are the <datalist> tag and <select> tag the same?</select></datalist>

A

The <datalist> tag provides a list of suggested values for an <input></input> element, while the <select> tag creates a dropdown list where users can select one or more options from a predefined set.</select></datalist>

110
Q

What are the 3 required parts of HTML?

A

The three required parts of HTML are:

1) DOCTYPE declaration: It defines the version of HTML being used and ensures proper rendering in different browsers.
2) <html> element: This element wraps all the content on the webpage and signifies the beginning of an HTML document.
3) <body> element: It contains the visible content of the webpage, such as text, images, links, and other elements displayed in the browser window.