10 Common JavaScript Interview Questions and How to Answer Them
Table of contents
What is the difference between a block element and an inline element? Give a few examples of block and inline tags which we have in HTML.
( HTML me block aur inline elements ka kya fark hai? Kuch block aur inline tags ke examples bataye )The Main difference between a block element and an inline element is that block takes up the full width of the parent container and creates a new line after them while inline elements only take up as much width of their content and do not create a new line.
Examples of block elements include
<h1> , <p>, <div>
while examples of inline elements include<span>, <a>, <img>
.( Block elements aur inline elements HTML me do tarah ke elements hote hai jo alag alag display properties rakhte hai. Block elements apne parent container ke full width ko occupy karte hai aur unke baad ek new line create karte hai. Examples
<h1> , <p>, <div>
.Inline elements sirf apni content ke width aur height ke sath hote hai. Ye mostly text based tags ke liye use kiye jate hai. Examples
<span>, <a>, <img>
)
What are pseudo-elements and pseudo-classes in CSS? Give some examples.
( CSS me pseudo-elements aur pseudo-classes kya hai? Kuchh examples de. )Pseudo-elements are used to select a specific part of elements and are denoted with a double colon
(::)
.For Example,
::before
and::after
can be used to add content before and after an element,::first-line
and::first-letter
can be used to style the first letter or line of an element.Pseudo-classes are used to select an element based on its state and properties and are denoted with a single colon
(:)
For Example,
:hover
,:active
,:visited
etc.( Pseudo elements kisi specific part ko select karne ke liye use kiye jate hai. Jaise
::before
,::after
,::first-line
and::first-letter
.Pseudo classes kisi element ko unke state or position ke base par select karne ke liye use kiye jate hai, jaise
:hover
,:active
,:visited,
:focus
and:checked
. )
What are CSS positions? What are the position types in CSS? What is the default position property in CSS?
( CSS me position kya hota hai? CSS me Kaun si position types hoti hai? CSS me default position property kya hai? )CSS positions are used to set the position of an element. The position types are static, relative, absolute, fixed and sticky.
The default position property is static which means the element is positioned in the normal flow of the document.
Relative positions allow you to offset an element from its current position.
Absolute positions allow you to set the element at a specific location on the screen.
Fixed positions fix the element at a specific location on the screen.
Sticky positions allow the element to remain in a specific location until a certain point is reached while scrolling.
( CSS me position kisi element ko specific place par set karna hota hai. Position types - static, relative, absolute, fixed, sticky hai.
Static position default hai, jisme element normal flow me position hota hai.
Relative position me hum element ke current position se offset de sakte hai.
Absolute position me hum element ko specific coordinates par set kar sakte hai.
Fixed position me hum element ko browser window ke fixed position par set kar sakte hai, ye element window scroll hote hue bhi same position par rahega.
Sticky position me hum element ko normal flow me rakhte hue usko specific point tak scroll hote hue stick kar sakte hai. )
Subscribe to my newsletter
Read articles from Failure Coder directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by