Category: CSS Question And Answer
-
How media types in CSS work?
The four types of media properties are print, speech, and screen. Example of using print-media type: @media print { h2 { background-color: blue; } }
-
Differentiate between logical and physical tags.
Logical tags mainly focus on content and are older as compared to physical ones. Logical ones do not find much usage in presentation and terms of aesthetics. At the same time, physical ones find application in presentation.
-
What do you understand by pseudo-elements?
Pseudo-elements provide special effects to some selectors. CSS finds use in applying styles in HTML markups. If additional markup or style is not feasible for a document, the pseudo-elements help by allowing extra markup without interfering with the original document.
-
Tell us about CSS float property.
The float property of CSS positions an image to the right or left as needed, including text wrapping around it. All properties of elements used before it remain unchanged.
-
Differentiate between the use of ID selector and class selector.
ID Selector: <style> { text-align: right; color: blue; } </style> CSS class Selector: <style> .right { text-align: right; color: blue; } </style>
-
How can you optimize the webpage for prints?
Identify and control ‘content areas’ of the website. A website generally has a footer, header, sidebar, navbar, and main content area. Most of the work is done by controlling the content area. So, conquer print media without changing the website’s integrity by using page breaks, creating a stylesheet for print, size your page for print, and…
-
What are mixins?
A mixin is similar to a function block of code returning a single value—mixin output lines of Sass code that directly compiles into CSS styles. At the same time, the function returns a value that becomes the value for a CSS property or something that can be passed to another mixin.
-
Name different ways to position some aspects in CSS.
The positioning property specifies the positioning method type. The five different position values are fixed, static, absolute, sticky, and relative. The elements are positioned using top, left, right, and bottom properties. These properties need to be set first, and they work depending on position value.
-
When should you use translate () instead of absolute positioning?
Translate is a CSS transform value. On changing opacity or transform, browser reflow or repaint is not triggered. Transform requires the browser to create a GPU layer for elements but using the CPU changes absolutes positioning properties. Translate () is more efficient and results in shorter paint times. On using translate (), element occupies original…
-
Does this property work overflow: hidden?
Overflow: the hidden property is used to specify the content’s clipping. We need to add scrollbars to the content area at the time of specified container size exceeding the content limit where the content gets enclosed. This makes the content invisible via clipping; also the overflow value will be hidden.