There is HTML with a nested stylesheet:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Margin test</title>
    <style type="text/css">
      #div1 {
        position: absolute;
        width: 200px;
        height: 100px;
        border: none;
        padding: 0;
        background: green;

      #div2 {
        margin-top: 20%;
        border: none;
        padding: 0;
        background: red;
        color: red;
    <div id="div1">
      <div id="div2">*</div>
What will be the margin-top value for the block with identifier div2 calculated in pixels?
To calculate the percentage value for the indentation of the element (including margin-top and margin-bottom), the width of the parent block (which contains this element) is always taken as a basis.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з HTML & CSS
Зареєструйся Зараз
або Підпишись на майбутні тести