Set width to 100% in HTML and CSS

Description

The following code shows how to set width to 100%.

Example


<!-- www  . ja va  2s .c om-->





<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Experimenting with Percentage Measurement</title>
<style type='text/css'>
div {
width: 100%;
background: black;
color: white;
}
</style>
</head>
<body>
<div>What happens when I apply a 100% width?</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set width to 100% in HTML and CSS