简体   繁体   中英

how can I change the position of html text?

I'm new to web development. here is my html code:

<html>
    <body>
        {errors}
        <p>Enter your numbers:</p>
        <form method="post" action=".">
            <p><input name="number1" /></p>
            <p><input name="number2" /></p>
            <p><input type="submit" value="Do calculation" /></p>
        </form>
    </body>
</html>

You can see how it appears below:

在此处输入图片说明

How can I change the position and font and size? it is currently being shown at the top left corner.

On web development, any time you need to style an element of your page, you need to use CSS. Have a look at w3school if you want to learn more about it.

In this case I'm going to show you how to apply internal styles, but you can apply CSS with external or inlined styles as well - Have a look here for an explanation of it.

 <html> <head> <style> body { font-family: 'Calibri', 'sans-serif'; font-size: 16px; font-weight: bold; text-align:center; } form { position: relative; bottom: 0; right: 0; } </style> </head> <body> {errors} <p>Enter your numbers:</p> <form method="post" action="."> <p><input name="number1" /></p> <p><input name="number2" /></p> <p><input type="submit" value="Do calculation" /></p> </form> </body> </html>

So in here, I gave you an example of how to use:

  • font-family - used to change the font type

  • font-size - to change size of the font

  • font-weight - to change the thickness of the font

  • position - used to position your element differently, by combining it with the use of top, left, right and bottom attributes

  • See here to know more about CSS font styles

  • See here to know more about CSS positioning

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM