HTML and CSS Questions
HTML and CSS Questions
1. <div> vs <span>
o Answer: <div> is a block-level element that creates a new line before and
after it. It is used for structuring the layout. <span> is an inline element that
does not cause line breaks and is used for styling parts of text.
2. Difference between box-sizing: border-box and content-box
o Answer: content-box (default) calculates width/height based only on the
content. border-box includes padding and border in the element's total
width/height, making layout easier.
3. HTML5 Features
o Answer: An image is a static file displayed on the web, while an image map
allows different clickable areas (hotspots) of the image to link to different
URLs, typically defined using <map> and <area> elements.
o Answer: The CSS box model describes the rectangular boxes generated for
elements in a document tree and includes margins, borders, padding, and the
actual content area.
o Answer: Use flexible grids (e.g., CSS Grid and Flexbox), media queries for
adaptive styles, and relative units (%, em, rem) for sizing elements and layout
adjustments across different screen sizes.
Address : ByteSplash Training and Placement Center, 4th Floor, No 92/9, PR Layout, Marathahalli, Bengaluru, Karnataka, 560037
Mobile : +91 8660803099 / +91 6301062858 , Email : [email protected]
Corporate Training and Placement Center
layouts using rows and columns simultaneously. Use display: flex; for
Flexbox and display: grid; for Grid layout.
Answer: <meta> tags provide metadata about the HTML document, including
o
keywords for SEO, character set (UTF-8), viewport settings for responsive
design, and descriptions.
11. How to combine 2 columns with rowspan="2"?
o Answer: Use a <table> structure with <td> elements and
apply rowspan="2" to the desired cell, combining it vertically over two rows.
12. display: none vs. visibility: hidden
o Answer: display: none removes the element from the document flow (no
space is occupied). visibility: hidden hides it but maintains its space in
the layout.
<input list="options"/>
<datalist id="options">
<option value="Option 1">
<option value="Option 2">
</datalist>
Address : ByteSplash Training and Placement Center, 4th Floor, No 92/9, PR Layout, Marathahalli, Bengaluru, Karnataka, 560037
Mobile : +91 8660803099 / +91 6301062858 , Email : [email protected]
Corporate Training and Placement Center
17. Implementing name="gender" in HTML (Checkbox)
o Answer: Use checkboxes with the same name for a group:
o Answer:
▪ localStorage: Can hold up to 5-10MB indefinitely.
▪ sessionStorage: Similar to localStorage but only lasts for the
session.
▪ Cookies: Limited to 4KB, used for server side communication and can
have expiration dates.
21. Cookies
oAnswer: A small piece of data sent to the browser by the server, limited to
around 4KB in size, used for storing user's session information.
22. Using <video> and <audio> Tags
o Answer: Use <video src="file.mp4" controls> and <audio
src="audio.mp3" controls> to embed media with controls for playback.
javascript
navigator.geolocation.getCurrentPosition((position) => {
console.log(position.coords.latitude, position.coords.longitude);
});
24. Check Online Status with navigator.onLine
Address : ByteSplash Training and Placement Center, 4th Floor, No 92/9, PR Layout, Marathahalli, Bengaluru, Karnataka, 560037
Mobile : +91 8660803099 / +91 6301062858 , Email : [email protected]
Corporate Training and Placement Center
o Answer: navigator.onLine returns a boolean indicating whether the browser
is online or offline:
o Answer: Margin, border, padding, and content determine the total size of an
element, e.g.,
o Answer: Use . for class selectors (e.g., .classname) and # for ID selectors
(e.g., #idname) in CSS. Example of linear gradient:
Address : ByteSplash Training and Placement Center, 4th Floor, No 92/9, PR Layout, Marathahalli, Bengaluru, Karnataka, 560037
Mobile : +91 8660803099 / +91 6301062858 , Email : [email protected]
Corporate Training and Placement Center
31. Sibling Selectors: ~ and +
o Answer:
▪ + selects the immediate next sibling.
▪ ~ selects all subsequent siblings.
Example:
css
o Answer: The total calculated width and height of a box can be determined by
the following:
Address : ByteSplash Training and Placement Center, 4th Floor, No 92/9, PR Layout, Marathahalli, Bengaluru, Karnataka, 560037
Mobile : +91 8660803099 / +91 6301062858 , Email : [email protected]