title: How to set div center vertically
body: <p>I am trying to align div element centre vertically using below code but it's not working I am trying to get this since a long time but no result can someone help me please where did I do my stack and how can I</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.center {
      padding: 10px 0;
      border: 3px solid green;
      margin-left:10px;
      margin-right:10px;
    }
   </code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
      
      &lt;h2&gt;Center Vertically&lt;/h2&gt;
      &lt;p&gt;In this example, we use the padding property to center the div element vertically:&lt;/p&gt;
      
      &lt;div class="center"&gt;
        &lt;p&gt;I am vertically centered.&lt;/p&gt;
        &lt;form action="/action_page.php"&gt;
        &lt;fieldset&gt;
          &lt;legend&gt;Personal information:&lt;/legend&gt;
          First name:&lt;br&gt;
          &lt;input type="text" name="firstname" value="Mickey"&gt;&lt;br&gt;
          Last name:&lt;br&gt;
          &lt;input type="text" name="lastname" value="Mouse"&gt;&lt;br&gt;&lt;br&gt;
          &lt;input type="submit" value="Submit"&gt;
        &lt;/fieldset&gt;
      &lt;/form&gt;
      &lt;/div&gt;
      
      &lt;/body&gt;
      &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>solve this?</p>
  
  <p><a href="https://www.w3schools.com/code/tryit.asp?filename=FYB6T0NY6DTE" rel="nofollow noreferrer">https://www.w3schools.com/code/tryit.asp?filename=FYB6T0NY6DTE</a></p>