The top value is not valid and does not work unless the position:absolute; top value is set

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <meta charset="utf-8" />
    <style type="text/css">
 
        -sharpdiv1{
            height:300px;
            width:300px;
            background-color:red;
            top:100px;
            left:100px;
        }
    </style>
</head>
<body>
    <div id="div1"></div>
    <div id="div2"></div>
    <!--idclass-->
</body>
</html>
reason: the top attribute specifies the top edge of the element. This attribute defines the offset between the upper outer margin boundary of an positioning element and the upper boundary of its containing block. If the value of the "position" property is "static", setting the "top" property has no effect.
Why?
Css
Mar.28,2021

relative, absolute, fixed takes effect only if, top left right bottom is located; static is not positioned.


only elements that are detached from the document stream will take effect, fixed absolute relative

Menu