Use percentage value to set width and height in HTML and CSS

Description

The following code shows how to use percentage value to set width and height.

Example


<!--from  w w  w .  java 2 s  .  co  m-->




<html>
<head>

<style type='text/css'>
p {
width: 100%;
height: 100%;
margin:  10px;
padding: 10px;
border:  1px solid black;
background: lightgray;
}
</style>
</head>
<body>
<p>
It is not a bad idea to get in the habit of writing down one's thoughts. It
saves one having to bother anyone else with them.
- Isabel Colegate
</p>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use percentage value to set width and height in HTML and CSS