title: How to Center Text in a JavaScript Function?
body: <p>I have a JavaScript function that displays text based on input in a text field. When a value is entered into the text field, my program will check to see if the value is correct. If it is correct, my program displays, "You are correct!" and if it is incorrect, my program displays, "Try again!"</p>
  
  <p>The text field and button are both centered horizontally on the page, but I cannot figure out how to center the "You are correct!" and "Try again!"</p>
  
  <p>I feel like I have tried everything, but obviously I haven't, considering I can't get it to work.</p>
  
  <p><strong>Here is the code for my JavaScript function:</strong></p>
  
  <pre><code>&lt;center&gt;&lt;p&gt;Can you remember how many books I listed at the bottom of the page?&lt;/p&gt;&lt;/center&gt;
  
  &lt;center&gt;&lt;input id="numb"&gt;&lt;/center&gt;
  
  &lt;center&gt;&lt;button type="button" onclick="myFunction()"&gt;Submit&lt;/button&gt;&lt;/center&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;div class="jsFunction"&gt;
  &lt;script&gt;
  function myFunction() 
  {
      var x, text;
  
      // Get the value of the input field with id="numb"
      x = document.getElementById("numb").value;
  
      // If x is Not a Number or less than five or greater than five
      if (isNaN(x) || x &lt; 5 || x &gt; 5) 
      {
          text = "Try again!";
      } 
      else 
      {
          text = "You are correct!";
      }
      document.getElementById("demo").innerHTML = text;
  }
  &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Here is the CSS code for the function:</strong></p>
  
  <pre><code>.jsFunction
  {
      margin-left: auto;
      margin-right: auto;
  }
  </code></pre>
  
  <p>This specific CSS code is only one of many, many attempts I have made at centering the text in the function.</p>
  
  <p><strong>Here is a link to a picture that will show you the problem I am having:</strong>
  <a href="http://i.stack.imgur.com/Hb01j.png" rel="nofollow">http://i.stack.imgur.com/Hb01j.png</a></p>
  
  <p>Please help!</p>