Empty div (with style: height) will not display










14















Incredibly simple piece of HTML - but not displaying how I would expect.



I'm trying to create an empty div that displays as whitespace on the top of the page, with style="height: 400px;"



Even though I have specified a height, my empty div will not display. What am I missing here?



UPDATE: my main question is: Why does an empty div not display even if it has a height set? Or, what are the basic style rules needed to display an empty div?



Full code:



<html>
<head><title>Site Name</title>
</head>
<body>
<div style="height:400px; width:100%; margin:0; padding:0; position:absolute;"></div>
<div style="width: 50%; margin: auto;">
<img src="logo.gif"></div>

<div style="width: 50%; margin: auto;"></div>

</body>
</html>









share|improve this question



















  • 2





    Try adding display:block;

    – rfoo
    Sep 25 '13 at 1:41











  • What are you expecting to see?

    – jono
    Sep 25 '13 at 1:43











  • I made this fiddle and added borders to your divs. What are you expecting? jsfiddle.net/KyQgg/4

    – rfoo
    Sep 25 '13 at 1:44












  • @rosscowar I want the first div div style="height:400px; width:100%; margin:0; padding:0; position:absolute;" to display. Essentially I'm trying to really quickly create whitespace.

    – azochz
    Sep 25 '13 at 1:53












  • Well if you see in the fiddle, it is displaying. If you want white space for that other div consider adding, margin-top:400px;

    – rfoo
    Sep 25 '13 at 1:57















14















Incredibly simple piece of HTML - but not displaying how I would expect.



I'm trying to create an empty div that displays as whitespace on the top of the page, with style="height: 400px;"



Even though I have specified a height, my empty div will not display. What am I missing here?



UPDATE: my main question is: Why does an empty div not display even if it has a height set? Or, what are the basic style rules needed to display an empty div?



Full code:



<html>
<head><title>Site Name</title>
</head>
<body>
<div style="height:400px; width:100%; margin:0; padding:0; position:absolute;"></div>
<div style="width: 50%; margin: auto;">
<img src="logo.gif"></div>

<div style="width: 50%; margin: auto;"></div>

</body>
</html>









share|improve this question



















  • 2





    Try adding display:block;

    – rfoo
    Sep 25 '13 at 1:41











  • What are you expecting to see?

    – jono
    Sep 25 '13 at 1:43











  • I made this fiddle and added borders to your divs. What are you expecting? jsfiddle.net/KyQgg/4

    – rfoo
    Sep 25 '13 at 1:44












  • @rosscowar I want the first div div style="height:400px; width:100%; margin:0; padding:0; position:absolute;" to display. Essentially I'm trying to really quickly create whitespace.

    – azochz
    Sep 25 '13 at 1:53












  • Well if you see in the fiddle, it is displaying. If you want white space for that other div consider adding, margin-top:400px;

    – rfoo
    Sep 25 '13 at 1:57













14












14








14


2






Incredibly simple piece of HTML - but not displaying how I would expect.



I'm trying to create an empty div that displays as whitespace on the top of the page, with style="height: 400px;"



Even though I have specified a height, my empty div will not display. What am I missing here?



UPDATE: my main question is: Why does an empty div not display even if it has a height set? Or, what are the basic style rules needed to display an empty div?



Full code:



<html>
<head><title>Site Name</title>
</head>
<body>
<div style="height:400px; width:100%; margin:0; padding:0; position:absolute;"></div>
<div style="width: 50%; margin: auto;">
<img src="logo.gif"></div>

<div style="width: 50%; margin: auto;"></div>

</body>
</html>









share|improve this question
















Incredibly simple piece of HTML - but not displaying how I would expect.



I'm trying to create an empty div that displays as whitespace on the top of the page, with style="height: 400px;"



Even though I have specified a height, my empty div will not display. What am I missing here?



UPDATE: my main question is: Why does an empty div not display even if it has a height set? Or, what are the basic style rules needed to display an empty div?



Full code:



<html>
<head><title>Site Name</title>
</head>
<body>
<div style="height:400px; width:100%; margin:0; padding:0; position:absolute;"></div>
<div style="width: 50%; margin: auto;">
<img src="logo.gif"></div>

<div style="width: 50%; margin: auto;"></div>

</body>
</html>






css html5 css3 html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 25 '13 at 1:56







azochz

















asked Sep 25 '13 at 1:39









azochzazochz

3652417




3652417







  • 2





    Try adding display:block;

    – rfoo
    Sep 25 '13 at 1:41











  • What are you expecting to see?

    – jono
    Sep 25 '13 at 1:43











  • I made this fiddle and added borders to your divs. What are you expecting? jsfiddle.net/KyQgg/4

    – rfoo
    Sep 25 '13 at 1:44












  • @rosscowar I want the first div div style="height:400px; width:100%; margin:0; padding:0; position:absolute;" to display. Essentially I'm trying to really quickly create whitespace.

    – azochz
    Sep 25 '13 at 1:53












  • Well if you see in the fiddle, it is displaying. If you want white space for that other div consider adding, margin-top:400px;

    – rfoo
    Sep 25 '13 at 1:57












  • 2





    Try adding display:block;

    – rfoo
    Sep 25 '13 at 1:41











  • What are you expecting to see?

    – jono
    Sep 25 '13 at 1:43











  • I made this fiddle and added borders to your divs. What are you expecting? jsfiddle.net/KyQgg/4

    – rfoo
    Sep 25 '13 at 1:44












  • @rosscowar I want the first div div style="height:400px; width:100%; margin:0; padding:0; position:absolute;" to display. Essentially I'm trying to really quickly create whitespace.

    – azochz
    Sep 25 '13 at 1:53












  • Well if you see in the fiddle, it is displaying. If you want white space for that other div consider adding, margin-top:400px;

    – rfoo
    Sep 25 '13 at 1:57







2




2





Try adding display:block;

– rfoo
Sep 25 '13 at 1:41





Try adding display:block;

– rfoo
Sep 25 '13 at 1:41













What are you expecting to see?

– jono
Sep 25 '13 at 1:43





What are you expecting to see?

– jono
Sep 25 '13 at 1:43













I made this fiddle and added borders to your divs. What are you expecting? jsfiddle.net/KyQgg/4

– rfoo
Sep 25 '13 at 1:44






I made this fiddle and added borders to your divs. What are you expecting? jsfiddle.net/KyQgg/4

– rfoo
Sep 25 '13 at 1:44














@rosscowar I want the first div div style="height:400px; width:100%; margin:0; padding:0; position:absolute;" to display. Essentially I'm trying to really quickly create whitespace.

– azochz
Sep 25 '13 at 1:53






@rosscowar I want the first div div style="height:400px; width:100%; margin:0; padding:0; position:absolute;" to display. Essentially I'm trying to really quickly create whitespace.

– azochz
Sep 25 '13 at 1:53














Well if you see in the fiddle, it is displaying. If you want white space for that other div consider adding, margin-top:400px;

– rfoo
Sep 25 '13 at 1:57





Well if you see in the fiddle, it is displaying. If you want white space for that other div consider adding, margin-top:400px;

– rfoo
Sep 25 '13 at 1:57












4 Answers
4






active

oldest

votes


















15














If you just want to add white space try this



<div style="height:400px; width:100%; clear:both;"></div>


FIDDLE



or you could just add padding to the body like body padding-top: 400px;






share|improve this answer

























  • Doesn't work if you use height: 50%. How to make it work?

    – akaltar
    Jun 28 '16 at 17:34


















6














The css style you are looking for is min-height: 20px; By default a div without content will have a height of 0 due to the auto setting being the default which sizes itself to fit content.



enter image description here



enter image description here






share|improve this answer























  • That is a brilliant solution!

    – Rabbi Shuki Gur
    Jan 15 '18 at 14:47


















3














You need to add a background so you can see the white box.



background-color:black;


You won't be able to see it.






share|improve this answer
































    0














    The reason it did not display is because you had position:absolute in your style. That means that div will be positioned independently of the other elements, and have no effect on the div that follows. So your second div is essentially the first div on the screen.






    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18994830%2fempty-div-with-style-height-will-not-display%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      15














      If you just want to add white space try this



      <div style="height:400px; width:100%; clear:both;"></div>


      FIDDLE



      or you could just add padding to the body like body padding-top: 400px;






      share|improve this answer

























      • Doesn't work if you use height: 50%. How to make it work?

        – akaltar
        Jun 28 '16 at 17:34















      15














      If you just want to add white space try this



      <div style="height:400px; width:100%; clear:both;"></div>


      FIDDLE



      or you could just add padding to the body like body padding-top: 400px;






      share|improve this answer

























      • Doesn't work if you use height: 50%. How to make it work?

        – akaltar
        Jun 28 '16 at 17:34













      15












      15








      15







      If you just want to add white space try this



      <div style="height:400px; width:100%; clear:both;"></div>


      FIDDLE



      or you could just add padding to the body like body padding-top: 400px;






      share|improve this answer















      If you just want to add white space try this



      <div style="height:400px; width:100%; clear:both;"></div>


      FIDDLE



      or you could just add padding to the body like body padding-top: 400px;







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Sep 25 '13 at 1:56

























      answered Sep 25 '13 at 1:51









      mdesdevmdesdev

      5,06011327




      5,06011327












      • Doesn't work if you use height: 50%. How to make it work?

        – akaltar
        Jun 28 '16 at 17:34

















      • Doesn't work if you use height: 50%. How to make it work?

        – akaltar
        Jun 28 '16 at 17:34
















      Doesn't work if you use height: 50%. How to make it work?

      – akaltar
      Jun 28 '16 at 17:34





      Doesn't work if you use height: 50%. How to make it work?

      – akaltar
      Jun 28 '16 at 17:34













      6














      The css style you are looking for is min-height: 20px; By default a div without content will have a height of 0 due to the auto setting being the default which sizes itself to fit content.



      enter image description here



      enter image description here






      share|improve this answer























      • That is a brilliant solution!

        – Rabbi Shuki Gur
        Jan 15 '18 at 14:47















      6














      The css style you are looking for is min-height: 20px; By default a div without content will have a height of 0 due to the auto setting being the default which sizes itself to fit content.



      enter image description here



      enter image description here






      share|improve this answer























      • That is a brilliant solution!

        – Rabbi Shuki Gur
        Jan 15 '18 at 14:47













      6












      6








      6







      The css style you are looking for is min-height: 20px; By default a div without content will have a height of 0 due to the auto setting being the default which sizes itself to fit content.



      enter image description here



      enter image description here






      share|improve this answer













      The css style you are looking for is min-height: 20px; By default a div without content will have a height of 0 due to the auto setting being the default which sizes itself to fit content.



      enter image description here



      enter image description here







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 29 '16 at 16:02









      Dmitri LarionovDmitri Larionov

      14728




      14728












      • That is a brilliant solution!

        – Rabbi Shuki Gur
        Jan 15 '18 at 14:47

















      • That is a brilliant solution!

        – Rabbi Shuki Gur
        Jan 15 '18 at 14:47
















      That is a brilliant solution!

      – Rabbi Shuki Gur
      Jan 15 '18 at 14:47





      That is a brilliant solution!

      – Rabbi Shuki Gur
      Jan 15 '18 at 14:47











      3














      You need to add a background so you can see the white box.



      background-color:black;


      You won't be able to see it.






      share|improve this answer





























        3














        You need to add a background so you can see the white box.



        background-color:black;


        You won't be able to see it.






        share|improve this answer



























          3












          3








          3







          You need to add a background so you can see the white box.



          background-color:black;


          You won't be able to see it.






          share|improve this answer















          You need to add a background so you can see the white box.



          background-color:black;


          You won't be able to see it.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 25 '13 at 1:54

























          answered Sep 25 '13 at 1:48









          ShaunShaun

          366213




          366213





















              0














              The reason it did not display is because you had position:absolute in your style. That means that div will be positioned independently of the other elements, and have no effect on the div that follows. So your second div is essentially the first div on the screen.






              share|improve this answer



























                0














                The reason it did not display is because you had position:absolute in your style. That means that div will be positioned independently of the other elements, and have no effect on the div that follows. So your second div is essentially the first div on the screen.






                share|improve this answer

























                  0












                  0








                  0







                  The reason it did not display is because you had position:absolute in your style. That means that div will be positioned independently of the other elements, and have no effect on the div that follows. So your second div is essentially the first div on the screen.






                  share|improve this answer













                  The reason it did not display is because you had position:absolute in your style. That means that div will be positioned independently of the other elements, and have no effect on the div that follows. So your second div is essentially the first div on the screen.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 18 '17 at 16:23









                  broc.seibbroc.seib

                  14.7k64848




                  14.7k64848



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18994830%2fempty-div-with-style-height-will-not-display%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                      ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

                      Node.js puppeteer - Use values from array in a loop to cycle through pages