HTML CSS examples for CSS Property:background-color
Make the colored background to be 50% of page width
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .somebackground {<!-- ww w.j a v a 2s .c om--> background:red; display:inline-block; min-width:50%; max-width:90%; overflow:auto; padding:5px; } </style> </head> <body> <pre class="somebackground"> <code>Hello</code> </pre> <br> <br> <pre class="somebackground"> <code>Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello </code> </pre> <br> <br> <pre class="somebackground"> <code>Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello </code> </pre> </body> </html>