print in landscape mode html css code example

Example 1: detect portrait landscape css

@media screen and (orientation:portrait) {}
 @media screen and (orientation:landscape) {}

Example 2: force landscape mode css

<style type="text/css">
    #warning-message{ 
      display: none; 
	}
    @media only screen and (orientation:portrait){
        #wrapper { 
          display:none; 
      	}
        #warning-message { 
          display:block; 
      	}
    }
    @media only screen and (orientation:landscape){
        #warning-message{
          display:none; 
      }
    }
</style>

....

<div id="wrapper">
    <!-- your html for your website -->
</div>
<div id="warning-message">
    this website is only viewable in landscape mode
</div>

Tags:

Css Example