0% found this document useful (0 votes)
18 views2 pages

HTML & CSS Interview Questions Guide

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

HTML & CSS Interview Questions Guide

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HTML & CSS Test

1) What is <!DOCTYPE html> and write an example ?


2) What is the HTML layout structure?
3) What is Element and Tag and Element_Name and write an
example ?
4) What is an Attribute and write an example ?
5) What difference b/w DIV and SPAN tag and write an example ?
6) What is Image Tag and Example (write 2 attributes with tag)
?
7) What is Anchor Tag and Example (write 2 attributes with
tag) ?
8) What is Class and ID in HTML and write examples ?
9) What are Semantic Elements and write an example ?
10) What is HTML5 Advantage and write examples ?
11) What is <ul> and <ol> and <li> and write examples(with
type and start attribute) ?
12) What are Block level elements and write examples ?
13) What are Inline elements and write an example ?
14) What are void elements in HTML and write examples?
15) If I write Text Content in the body it will display in
Browser or Not ? Why are we using Elements and Tags in HTML
?

—---------------------------------------------------------------
----

16)What are different types of Selectors in CSS and write


examples?
17)What is the BOX model in CSS and a write Diagram?
18)What is the difference b/w Inline style and Internal Style
and external Style and writing example ?
19)What is Pseudo Element and Pseudo Class and write examples?
20)Explain CSS all position property and examples ?
21)Why do we use @media properties in CSS?
22)Write all types of properties in CSS FLEX ?
23)Which properties do we use to display TEXT in the center of
the page?
24)Which property do we use for Square BOX and Circle shape in
CSS ?
25)what is the difference b/w “Display:None” and
“visibility:Hidden” property in CSS?

Common questions

Powered by AI

The <!DOCTYPE html> declaration informs the web browser about the version of HTML the page is written in. It ensures that the browser renders the web page correctly by specifying standards mode as opposed to quirks mode, thus promoting consistent display across different browsers. An example of its structure is simply <!DOCTYPE html> at the very top of an HTML document. This is particularly important as it helps prevent unexpected behaviors that might occur if the browser makes assumptions about the type of document. Its presence or absence can drastically alter how the page elements are rendered .

CSS selectors are used to select HTML elements based on their id, class, type, attribute, and more, facilitating the application of styles to specific elements. They function by targeting elements to apply CSS rules, enabling comprehensive styling with minimal code. Examples include the class selector (e.g., .example selects all elements with class 'example'), the id selector (e.g., #header targets the element with id='header'), and the attribute selector (e.g., [type='text'] selects all inputs of type 'text'). CSS selectors enhance the separation of style from content, promoting easier maintenance and readability of web code .

'@media' queries are a core component of responsive web design, allowing CSS to apply styles based on device characteristics like screen size, orientation, and resolution. They enable developers to create adaptable layouts that adjust to different viewing contexts, ensuring accessibility and usability across a wide range of devices. For instance, @media (max-width: 600px) {body {background-color: lightblue;}} changes the background color when the screen width is 600px or less. This flexibility is essential in modern web development where user experience must be optimized for both mobile and desktop environments .

The <ul> element represents an unordered list that is typically displayed with bullet points, while the <ol> element represents an ordered list that is displayed with numerical or alphabetical order. Both use <li> elements to define each list item. The semantic meaning lies in their visualization of data; unordered lists imply no particular sequence, while ordered lists emphasize the importance of order. An example of an ordered list with 'type' and 'start' attributes can be: <ol type='A' start='3'><li>Item C</li></ol>, which would start the list at 'C' using alphabetical notation, showcasing the flexibility of presentation .

The 'div' and 'span' elements are both used for grouping content, but they serve different purposes. A 'div' is a block-level element, which means it typically starts on a new line and takes up the full width available. For instance, <div>This is a block</div> will break lines before and after. A 'span', conversely, is an inline element used to style a part of text or group small elements together without adding line breaks, like <span>This is inline</span> within a paragraph. Choosing between them depends on whether you need to control large layout sections with 'div' or target a specific text style or part of content with 'span' .

Block-level elements, such as <div>, <p>, or <header>, start on new lines and stretch across the full width of their container, which allows them to define large structure sections in a webpage. Inline elements, like <span>, <a>, and <strong>, do not break the flow of text and remain within the context of their surrounding text. This distinction is crucial for web layout as it directly impacts the arrangement and grouping of content, facilitating responsive designs and structured page layouts. Properly understanding and using these allows developers to create intuitive, well-organized content structures .

Pseudo-elements are used to style specified parts of an element, such as ::before and ::after, which insert content before or after an element's content. For instance, p::before {content: 'Note: ';} adds 'Note: ' before each paragraph text. Pseudo-classes, like :hover or :focus, apply styles when an element is in a specific state. For example, a:hover {color: red;} changes the link color to red when hovered. They offer powerful ways to enhance visual state changes and interact with document object models without scripting, greatly improving user interface experiences .

HTML5 introduced several advantages over its predecessors, including simplified syntax, enhanced multimedia integration, and improved error handling. Notable features include new semantic elements like <header>, <footer>, and <article> that add meaning and structure to the content, thus improving accessibility and SEO. Furthermore, HTML5 provides built-in support for audio and video, eliminating the need for third-party plugins. Another significant improvement is better browser compatibility and tools like Web Workers that improve script execution without affecting the user interface .

'Display:none' removes an element from the document flow entirely, meaning it does not occupy space on the page. 'Visibility:hidden,' however, makes an element invisible but leaves its space in the layout, affecting surrounding elements. 'Display:none' is often used when managing modal views or dropdowns where an element might be toggled on or off without affecting layout. 'Visibility:hidden' is useful when the presence of an element must be maintained visually invisible but still impact layout decisions, preserving spatial relationships on the page .

The CSS 'box model' is a fundamental concept that defines the structure of every HTML element as a rectangular box consisting of margins, borders, padding, and the actual content. The box model affects layout calculations by determining how elements are sized and spaced in relation to one another. For instance, the total width of an element is calculated as width + padding + border + margin. Understanding the box model is crucial for accurately controlling layout behaviors and preventing design issues related to spacing. A visual representation includes a concentric diagram showing content at the core with successive layers of padding, border, and margin .

You might also like