CSS Interview Questions

1. What is CSS?

Answer: CSS stands for Cascading Style Sheets. It is a styling language used to describe the presentation of a document written in HTML.

2. How do you include CSS in an HTML document?

Answer: CSS can be included in an HTML document using the <style> tag within the <head> section or by linking an external CSS file using the <link> tag.

3. What are the different ways to apply CSS to HTML elements?

Answer: CSS can be applied to HTML elements using inline styles, internal stylesheets, or external stylesheets.

4. How do you select an element by its ID in CSS?

Answer: To select an element by its ID in CSS, use the # symbol followed by the ID name. For example, to select an element with the ID "myElement", use #myElement.

5. How do you select multiple elements with the same class in CSS?

Answer: To select multiple elements with the same class in CSS, use the . symbol followed by the class name. For example, to select all elements with the class "myClass", use .myClass.

6. What is the difference between classes and IDs in CSS?

Answer: Classes can be used to apply styles to multiple elements, while IDs are unique and can only be applied to a single element.

7. What are pseudo-classes in CSS?

Answer: Pseudo-classes are used to select elements that are in a specific state or position, such as :hover for styling elements when they are being hovered over by the mouse.

8. What is the box model in CSS?

Answer: The box model is a concept in CSS that represents an HTML element as a rectangular box. It consists of the content, padding, border, and margin.

9. How do you center an element horizontally in CSS?

Answer: To center an element horizontally in CSS, set its left and right margins to auto and give it a defined width.

10. How do you override CSS styles?

Answer: CSS styles can be overridden by using more specific selectors, using the !important declaration, or by placing the overriding styles after the original styles.

11. What is the difference between margin and padding in CSS?

Answer: Margin is the space outside the element, while padding is the space within the element, between the content and the border.

12. How do you create a responsive design in CSS?

Answer: To create a responsive design in CSS, use media queries to apply different styles based on the screen size or device.

13. What is the difference between display: block; and display: inline; in CSS?

Answer: display: block; makes an element a block-level element, taking up the full width of the container, while display: inline; makes an element an inline element, allowing other elements to be on the same line.

14. How do you apply a background image in CSS?

Answer: To apply a background image in CSS, use the background-image property and specify the URL of the image.

15. What is the box-sizing property used for?

Answer: The box-sizing property is used to control how the total width and height of an element is calculated, including or excluding the padding and border.

16. What is the difference between absolute and relative positioning in CSS?

Answer: Absolute positioning positions an element relative to its nearest positioned ancestor, while relative positioning positions an element relative to its normal position in the document flow.

17. How do you create a sticky footer in CSS?

Answer: To create a sticky footer in CSS, set the height of the footer to a fixed value and use position: fixed; to keep it at the bottom of the page.

18. What is a CSS preprocessor?

Answer: A CSS preprocessor is a scripting language that extends CSS and allows for the use of variables, functions, mixins, and other advanced features, making it easier to write and maintain CSS code.

19. What is the difference between :nth-child and :nth-of-type in CSS?

Answer: :nth-child selects elements based on their position among all siblings, while :nth-of-type selects elements based on their position among siblings of the same type.

20. How do you create a CSS gradient?

Answer: CSS gradients can be created using the background-image property with the linear-gradient() or radial-gradient() functions.

21. How do you vertically align text in CSS?

Answer: To vertically align text in CSS, use the vertical-align property on inline or table-cell elements.

22. How do you hide an element in CSS?

Answer: To hide an element in CSS, use the display: none; property.

23. What is the difference between :nth-child(even) and :nth-child(odd) in CSS?

Answer: :nth-child(even) selects elements with even positions among their siblings, while :nth-child(odd) selects elements with odd positions.

24. How do you create a responsive grid layout in CSS?

Answer: A responsive grid layout in CSS can be created using techniques such as flexbox or CSS grid.

25. What is the difference between em and rem units in CSS?

Answer: em units are relative to the font-size of the parent element, while rem units are relative to the font-size of the root element (usually the <html> element).

26. How do you animate an element in CSS?

Answer: An element can be animated in CSS using the @keyframes rule along with the animation property.

27. What is the purpose of the z-index property in CSS?

Answer: The z-index property in CSS is used to control the stacking order of positioned elements on the z-axis.

28. How do you create a dropdown menu in CSS?

Answer: A dropdown menu in CSS can be created using the combination of HTML <ul> and <li> elements, along with CSS for styling and display.

29. What is the float property used for in CSS?

Answer: The float property is used to specify whether an element should float to the left or right of its container, allowing other content to flow around it.

30. How do you create a tooltip in CSS?

Answer: A tooltip in CSS can be created by using the ::before or ::after pseudo-elements, along with CSS positioning and visibility properties.

31. What is the currentColor keyword in CSS?

Answer: The currentColor keyword in CSS is used to refer to the current color value set on an element, allowing it to be used in other properties like border-color or box-shadow.

32. How do you apply a transition to an element in CSS?

Answer: To apply a transition to an element in CSS, use the transition property along with the desired property to transition and the duration or timing function.

33. What is the purpose of the calc() function in CSS?

Answer: The calc() function in CSS is used to perform calculations to determine the value of a property, allowing for dynamic sizing and positioning.

34. How do you create a fixed header that scrolls with the page in CSS?

Answer: To create a fixed header that scrolls with the page in CSS, use the position: fixed; property along with aspecific height and the appropriate z-index value.

35. What is the CSS content property used for?

Answer: The CSS content property is used with pseudo-elements (::before and ::after) to insert generated content, such as text or images, into an element.

36. How do you target the last child element in CSS?

Answer: To target the last child element in CSS, you can use the :last-child pseudo-class selector.

37. How do you apply a border radius to only one corner of an element in CSS?

Answer: To apply a border radius to only one corner of an element in CSS, use the border-radius property and specify the radius values for each corner individually using the top-left, top-right, bottom-left, and bottom-right properties.

38. How do you create a responsive image that scales with its container in CSS?

Answer: To create a responsive image that scales with its container in CSS, set the max-width property of the image to 100% and the height property to auto.

39. What is the purpose of the box-shadow property in CSS?

Answer: The box-shadow property in CSS is used to add a shadow effect to an element, allowing you to control the color, size, blur, and position of the shadow.

40. How do you select the first letter of a paragraph in CSS?

Answer: To select the first letter of a paragraph in CSS, use the ::first-letter pseudo-element.

41. How do you apply a gradient background to text in CSS?

Answer: Applying a gradient background to text in CSS can be achieved using the -webkit-background-clip property with the -webkit-text value and setting the background-image property to a gradient.

42. What is the purpose of the object-fit property in CSS?

Answer: The object-fit property in CSS is used to specify how an image or video should be resized to fit its container, allowing options like contain or cover.

43. How do you create a responsive navigation menu in CSS?

Answer: A responsive navigation menu in CSS can be created using CSS media queries to hide or show different menu layouts based on the screen size or device.

44. What is the difference between :before and ::before in CSS?

Answer: :before and ::before are both used to create pseudo-elements, but ::before is the preferred syntax introduced in CSS3.

45. How do you disable text selection in CSS?

Answer: To disable text selection in CSS, use the user-select property and set it to none.

46. What is the purpose of the pointer-events property in CSS?

Answer: The pointer-events property in CSS is used to control whether an element can be the target of pointer events like clicks or hover interactions.

47. How do you create a responsive slideshow in CSS?

Answer: A responsive slideshow in CSS can be created using CSS animations, transitions, and keyframes, along with JavaScript to control the slideshow functionality.

48. What is the difference between :hover and :focus in CSS?

Answer: :hover is used to select an element when the mouse pointer is over it, while :focus is used to select an element when it has received focus, such as when it is clicked or selected using the keyboard.

49. How do you apply a grayscale filter to an image in CSS?

Answer: To apply a grayscale filter to an image in CSS, use the filter property and set it to grayscale(100%).

50. How do you create a multi-column layout in CSS?

Answer: A multi-column layout in CSS can be created using the column-count and column-width properties, along with other related properties like column-gap or column-rule.
Download
1. What is CSS?

Answer: CSS stands for Cascading Style Sheets. It is a style sheet language used to describe the presentation of a document written in HTML or XML.

2. What are the different ways to include CSS in an HTML document?

Answer: CSS can be included in an HTML document using inline styles, internal stylesheets, or external stylesheets.

3. How do you select an element with a specific class using CSS?

Answer: You can select an element with a specific class using the dot notation. For example, to select all elements with the class "my-class", you would use ".my-class" in your CSS selector.

4. What is the box model in CSS?

Answer: The box model in CSS describes the structure of an element. It consists of the content, padding, border, and margin of an element.

5. How do you center align a block-level element horizontally in CSS?

Answer: You can center align a block-level element horizontally by setting its left and right margins to "auto" and specifying a width for the element.

6. What is the difference between display: inline and display: block?

Answer: The display property "inline" makes an element behave like an inline element, allowing other elements to be displayed on the same line. The display property "block" makes an element behave like a block-level element, taking up the full width available.

7. How do you override the styles applied by another CSS rule?

Answer: You can override styles applied by another CSS rule by using a more specific selector or by using the !important declaration.

8. How can you hide an element from the page using CSS?

Answer: You can hide an element from the page using CSS by setting its display property to "none" or by using the visibility property set to "hidden".

9. What is the CSS pseudo-class?

Answer: CSS pseudo-classes are used to select and style elements that are in a specific state or position in relation to the document or user interaction, such as :hover, :active, or :first-child.

10. How do you apply different styles to different media types using CSS?

Answer: You can apply different styles to different media types using CSS media queries. Media queries allow you to target specific devices or screen sizes and apply different styles accordingly.

11. What is the "clearfix" technique in CSS?

Answer: The "clearfix" technique is used to clear the floated elements within a container. It prevents the container from collapsing and ensures that it expands to include the floated elements.

12. What is the difference between "em" and "rem" units in CSS?

Answer: The "em" unit in CSS is relative to the font-size of the element itself, while the "rem" unit is relative to the font-size of the root element (typically the <html> element).

13. What is the CSS specificity and how does it work?

Answer: CSS specificity is a measure of how specific a CSS selector is. It determines which CSS rule will be applied to an element when multiple rules target the same element. Specificity is calculated based on the type of selector, class, ID, and inline styles.

14. How do you vertically align text within an element in CSS?

Answer: You can vertically align text within an element using the "vertical-align" property. It is commonly used with table cells or inline elements.

15. How do you create a responsive layout in CSS?

Answer: To create a responsive layout in CSS, you can use CSS media queries to target different screen sizes and adjust the styles accordingly. You can also use flexible units like percentages and viewport units.

16. What is the difference between padding and margin in CSS?

Answer: Padding is the space between the content of an element and its border, while margin is the space between an element and its surrounding elements.

17. How do you change the color of a link when it is visited?

Answer: You can change the color of a link when it is visited using the CSS pseudo-class ":visited" and setting the desired styles.

18. How can you make a background image responsive in CSS?

Answer: You can make a background image responsive in CSS by using the "background-size: cover;" property. It ensures that the background image covers the entire element, regardless of its size.

19. What is the purpose of the z-index property in CSS?

Answer: The z-index property in CSS controls the stacking order of positioned elements. It determines which element should be displayed on top when elements overlap.

20. How do you create a gradient background in CSS?

Answer: You can create a gradient background in CSS using the "linear-gradient()" or "radial-gradient()" functions within the "background" property.

21. What is the difference between the :nth-child() and :nth-of-type() selectors?

Answer: The :nth-child() selector matches elements based on their position among their siblings, while the :nth-of-type() selector matches elements based on their position among elements of the same type.

22. How do you apply a transition effect to an element in CSS?

Answer: You can apply a transition effect to an element in CSS using the "transition" property. It allows you to define the duration, timing function, and other properties of the transition.

23. What is the "float" property in CSS used for?

Answer: The "float" property in CSS is used to specify whether an element should float to the left, right, or not at all within its parent container.

24. How do you select all direct child elements of a specific element using CSS?

Answer: You can select all direct child elements of a specific element using the ">" symbol. For example, to select all direct child <li> elements of a <ul>, you would use "ul > li" in your CSS selector.

25. How do you style the first letter or first line of a block of text in CSS?

Answer: You can style the first letter of a block of text using the ::first-letter pseudo-element, or style the first line of a block of text using the ::first-line pseudo-element.

26. What is the purpose of the "box-sizing" property in CSS?

Answer: The "box-sizing" property in CSS determines whether an element's width and height should include its padding and border. By default, it is set to "content-box", but you can change it to "border-box" to include padding and border.

27. How do you create a dropdown menu in CSS?

Answer: You can create a dropdown menu in CSS by using the combination of nested lists and CSS selectors. By hiding and showing the nested list, you can create the effect of a dropdown menu.

28. How can you apply different styles to an element when the mouse is over it?

Answer: You can apply different styles to an element when the mouse is over it using the :hover pseudo-class. It allows you to define styles that should be applied when the mouse pointer is over the element.

29. What is the difference between absolute positioning and relative positioning in CSS?

Answer: Absolute positioning in CSS positions an element relative to its nearest positioned ancestor, while relative positioning positions an element relative to its normal position in the document flow.

30. How do you create a sticky header/footer in CSS?

Answer: You can create a sticky header/footer in CSS by using the "position: sticky;" property on the header/footer element. This property ensures that the element remains fixed within its container when scrolling.

31. What is the difference between the "display: none;" and "visibility: hidden;" properties in CSS?

Answer: The "display: none;" property completely removes the element from the document flow, making it invisible and not taking up any space. The "visibility: hidden;" property hides the element but still occupies space in the document flow.

32. How do you vertically center an element in CSS?

Answer: You can vertically center an element in CSS by using the combination of "display: flex;" and "align-items: center;" properties on its parent container. Another approach is to use the "position: absolute;" and "top: 50%;" properties, combined with a negative margin-top value.

33. What is the purpose of the "pointer-events" property in CSS?

Answer: The "pointer-events" property in CSS allows you to control how an element responds to mouse events. It can be used to make an element ignore mouse events or to pass them through to elements below.

34. How do you create a fixed background image in CSS?

Answer: You can create a fixed background image in CSS by using the "background-attachment: fixed;" property. This property ensures that the background image remains fixed while the content scrolls.

35. What is the difference between the :before and :after pseudo-elements in CSS?

Answer: The :before pseudo-element inserts content before the content of an element, while the :after pseudo-element inserts content after the content of an element. They are often used to add decorative or additional content to elements.

36. How do you create a responsive grid layout in CSS?

Answer: You can create a responsive grid layout in CSS by using CSS Grid or CSS Flexbox. These layout systems provide flexible and responsive ways to organize and align elements in a grid-like structure.

37. What is the purpose of the "transform" property in CSS?

Answer: The "transform" property in CSS allows you to apply transformations to an element, such as scaling, rotating, skewing, or translating it. It enables you to create various visual effects and animations.

38. How do you change the text color of selected text using CSS?

Answer: You can change the text color of selected text using the ::selection pseudo-element and setting the desired styles.

39. What is the purpose of the "outline" property in CSS?

Answer: The "outline" property in CSS is used to create a visible outline around an element. It is similar to a border, but it does not affect the layout of the element or take up space.

40. How do you align elements horizontally in CSS?

Answer: You can align elements horizontally in CSS by using different techniques such as the "text-align" property, flexbox, or CSS Grid. The appropriate technique depends on the context and desired alignment behavior.

41. What is the purpose of the "text-overflow" property in CSS?

Answer: The "text-overflow" property in CSS specifies how overflowed content within an element should be displayed. It is commonly used to truncate text and show ellipsis (...) when the content exceeds the available space.

42. How do you create a responsive image in CSS?

Answer: You can create a responsive image in CSS by setting the max-width property to 100% and height to auto. This allows the image to scale proportionally and fit within its parent container.

43. What is the purpose of the "clip-path" property in CSS?

Answer: The "clip-path" property in CSS allows you to create custom clipping paths to control the visibility of an element. It can be used to create non-rectangular shapes or to hide parts of an element.

44. How do you disable text selection using CSS?

Answer: You can disable text selection using CSS by using the "user-select" property and setting it to "none". This property prevents the user from selecting and highlighting text.

45. What is the purpose of the "transform-origin" property in CSS?

Answer: The "transform-origin" property in CSS defines the origin point for transformations applied to an element. It determines the reference point for scaling, rotating, or skewing the element.

46. How do you create a tooltip in CSS?

Answer: You can create a tooltip in CSS by using the ::before or ::after pseudo-elements along with the "content" property to display additional information when hovering over an element. You can position the tooltip using CSS positioning or flexbox.

47. What is the purpose of the "word-wrap" property in CSS?

Answer: The "word-wrap" property in CSS determines whether long words can be broken and wrapped onto the next line. It is used to prevent long words from overflowing their container.

48. How do you create a responsive navigation menu in CSS?

Answer: You can create a responsive navigation menu in CSS by using media queries to adjust the styling and layout of the menu based on different screen sizes. Techniques like using flexbox or CSS Grid can help create a responsive menu structure.

49. What is the purpose of the "object-fit" property in CSS?

Answer: The "object-fit" property in CSS is used to specify how an image or video should be resized and fitted within its container. It controls the aspect ratio and positioning of the media content.

50. How do you change the appearance of a checkbox or radio button using CSS?

Answer: You can change the appearance of a checkbox or radio button using CSS by hiding the default input element and creating a custom styled element using labels, pseudo-elements, and CSS selectors.

Download
1. What is CSS?

Answer: CSS stands for Cascading Style Sheets. It is a stylesheet language used to describe the presentation of a document written in HTML or XML.

2. What are the different ways to include CSS styles in a web page?

Answer: CSS styles can be included in a web page using inline styles, internal stylesheets, or external stylesheets.

3. Explain the CSS box model.

Answer: The CSS box model is a design concept that describes how elements are rendered on a web page. It consists of content, padding, border, and margin.

4. What is the difference between margin and padding?

Answer: Margin is the space outside the border of an element, while padding is the space between the content and the border of an element.

5. How do you center an element horizontally in CSS?

Answer: You can center an element horizontally by setting the left and right margins to auto and giving it a specific width.

6. What is the difference between display: none and visibility: hidden?

Answer: display: none removes the element from the document flow and doesn't allocate any space, while visibility: hidden hides the element but still occupies space on the page.

7. How can you apply multiple CSS classes to an element?

Answer: You can apply multiple CSS classes to an element by adding them in the class attribute separated by spaces, like class="class1 class2".

8. What is the difference between inline and block elements?

Answer: Inline elements do not start on a new line and only take up as much space as necessary, while block elements start on a new line and occupy the full width available.

9. How do you override CSS specificity?

Answer: You can override CSS specificity by using a more specific selector, using the !important rule, or by rearranging the order of CSS rules.

10. What is the CSS clearfix technique used for?

Answer: The clearfix technique is used to clear the floated elements inside a container to ensure proper layout and prevent container collapse.

11. How can you create a fixed-width layout in CSS?

Answer: You can create a fixed-width layout by setting a specific width for the container or elements using pixels, percentages, or other length units.

12. Explain the CSS pseudo-classes :hover, :active, and :focus.

Answer: :hover is triggered when an element is being hovered over, :active is triggered when an element is being clicked, and :focus is triggered when an element is selected or receives focus.

13. What is the difference between absolute and relative positioning?

Answer: Absolute positioning positions an element relative to its closest positioned ancestor, while relative positioning positions an element relative to its normal position in the document flow.

14. How can you apply different styles to visited and unvisited links?

Answer: You can use the pseudo-classes :visited and :link to apply different styles to visited and unvisited links.

15. How do you create a responsive design in CSS?

Answer: You can create a responsive design by using media queries, flexible grid systems, and fluid layouts that adapt to different screen sizes.

16. What is the purpose of the z-index property in CSS?

Answer: The z-index property specifies the stack order of positioned elements. Elements with a higher z-index value will appear on top of elements with a lower value.

17. How can you vertically center an element in CSS?

Answer: You can vertically center an element by using flexbox, setting the line-height equal to the height of the container, or by using CSS transforms.

18. What is the purpose of the @media rule in CSS?

Answer: The @media rule is used to apply different styles for different media types or screen sizes, allowing you to create responsive designs.

19. How can you make an element's background image fixed while scrolling?

Answer: You can make an element's background image fixed while scrolling by using the background-attachment property with a value of fixed.

20. Explain the CSS3 flexbox layout.

Answer: The CSS3 flexbox layout is a flexible box model that allows you to create flexible and responsive layouts. It consists of flex containers and flex items.

21. How can you create a gradient background in CSS?

Answer: You can create a gradient background in CSS using the linear-gradient() or radial-gradient() functions.

22. What is the difference between pseudo-classes and pseudo-elements?

Answer: Pseudo-classes select elements based on their state or position, while pseudo-elements select and style specific parts of an element.

23. How do you hide an element visually but keep it accessible to screen readers?

Answer: You can hide an element visually but keep it accessible to screen readers by using the technique known as "visually hidden" or "screen reader only" text.

24. How can you vertically align text within an element?

Answer: You can vertically align text within an element by using the line-height property, flexbox, or CSS table layout.

25. What is the purpose of the CSS float property?

Answer: The float property is used to position elements horizontally, allowing text and other elements to wrap around them.

26. How can you create a responsive image in CSS?

Answer: You can create a responsive image by setting its max-width to 100% and height to auto, ensuring that the image scales proportionally with its container.

27. Explain the CSS transform property.

Answer: The transform property is used to apply 2D or 3D transformations to an element, such as rotating, scaling, skewing, or translating it.

28. How can you create a CSS tooltip?

Answer: You can create a CSS tooltip by using the ::before or ::after pseudo-elements and positioning them with absolute or relative positioning.

29. What is the difference between the rem and em units in CSS?

Answer: The rem unit is relative to the root element's font-size, while the em unit is relative to the font-size of the parent element.

30. How can you change the appearance of form elements in CSS?

Answer: You can change the appearance of form elements in CSS using pseudo-elements like ::before and ::after or by using CSS frameworks like Bootstrap.

31. What is the purpose of the CSS calc() function?

Answer: The calc() function is used to perform calculations to determine the value of a CSS property. It can be used to combine different units or perform mathematical operations.

32. How can you create an animated transition between two CSS states?

Answer: You can create an animated transition between two CSS states by using the transition property along with the desired CSS properties and duration.

33. Explain the CSS grid layout.

Answer: The CSS grid layout is a two-dimensional grid system that allows you to create complex and flexible layouts. It consists of grid containers and grid items.

34. How can you apply different styles based on the user's device orientation?

Answer: You can apply different styles based on the user's device orientation by using the @media rule with the orientation property.

35. What is the purpose of the CSS content property?

Answer: The content property is used with the ::before and ::after pseudo-elements to insert generated content before or after an element's content.

36. How can you create a sticky footer in CSS?

Answer: You can create a sticky footer by using flexbox, CSS grid, or by setting the position of the footer to fixed and adjusting the bottom value.

37. What is the purpose of the CSS filter property?

Answer: The filter property is used to apply visual effects like blur, grayscale, or brightness adjustments to an element's content.

38. How can you create a dropdown menu in CSS?

Answer: You can create a dropdown menu in CSS by using the combination of CSS selectors, positioning, and toggling display or visibility properties.

39. Explain the CSS pseudo-element ::first-letter.

Answer: The ::first-letter pseudo-element selects and styles the first letter of the first line of a block-level element.

40. How can you create a responsive navigation menu in CSS?

Answer: You can create a responsive navigation menu by using media queries, CSS transitions, and toggling the display or visibility of the menu items.

41. What is the purpose of the CSS flex-grow property?

Answer: The flex-grow property specifies how much an item should grow relative to other items in a flex container when there is extra space available.

42. How can you create a responsive video in CSS?

Answer: You can create a responsive video by wrapping the video element in a container and setting its width to 100% to ensure it scales with its container.

43. Explain the CSS3 animation property.

Answer: The animation property is used to create animations in CSS. It allows you to define keyframes, timing functions, and other animation properties.

44. How can you create a CSS-only slideshow?

Answer: You can create a CSS-only slideshow by using the :target pseudo-class and transitioning the visibility or opacity of the slides.

45. What is the purpose of the CSS counter-increment property?

Answer: The counter-increment property is used to increment or decrement the value of CSS counters, which can be used to generate automatic numbering or labeling.

46. How can you create a responsive equal-height grid in CSS?

Answer: You can create a responsive equal-height grid by using flexbox or CSS grid and setting the height of the grid items to 100%.

47. Explain the CSS position: sticky property.

Answer: The position: sticky property is used to make an element stick to its container or the viewport when scrolling reaches a specified threshold.

48. How can you create a CSS-only progress bar?

Answer: You can create a CSS-only progress bar by using the ::before or ::after pseudo-element, setting its width based on the progress value.

49. What is the purpose of the CSS perspective property?

Answer: The perspective property is used with 3D transformed elements to create a 3D perspective effect, altering the perception of depth in the scene.

50. How can you create a CSS print stylesheet?

Answer: You can create a CSS print stylesheet by using the @media rule with the print media type and defining specific styles for printing, such as hiding certain elements or adjusting page layout.
Download