Home  • Programming • CSS

Print specific part of webpage using CSS

<style type="text/css">
  @media print {
  body * {
    visibility: hidden;
  }
  #section-to-print, #section-to-print * {
    visibility: visible;
  }
  #section-to-print {
    position: absolute;
    left: 0;
    top: 0;
  }
}
</style>
Here is the complete code to use.
<html>
<head><title>Print</title>
<style type="text/css">
  @media print {
  body * {
    visibility: hidden;
  }
  #section-to-print, #section-to-print * {
    visibility: visible;
  }
  #section-to-print {
    position: absolute;
    left: 0;
    top: 0;
  }
}
</style>
</head>
<body>
    <div>
    	Your normal page contents
    </div>

    <div id="section-to-print ">
    	Printer version
    </div>
</body>
</html>

Comments 2


Thanks a lot Sir !
thx sir.............

Share

Copyright © 2024. Powered by Intellect Software Ltd