Percentages - HTML CSS CSS

HTML CSS examples for CSS:Length

Introduction

You can express a unit of measurement as a percentage of another property value.

The following code sets Units as a Percentage of Another Property Value.

Demo Code

ResultView the demo in separate window

<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
        <style type="text/css">
            p {<!--   w ww  . ja va  2  s .c  om-->
                background: grey;
                color:white;
                font-size: 200%;
                width: 50%;
            }
        </style>
    </head>
    <body>
        <a href="http://java2s.com">Website</a>
        <p>I like <span>CSS</span> and HTML.</p>
        <a class="myclass1 myclass2" href="http://w3c.org">Visit the W3C website</a>
    </body>
</html>

Related Tutorials