# Activity. Make a log-in page

** Desired outcome **
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660028131203/lQyNwv_kO.png align="left")

<hr>

- Make a box where the titles are in by using `<div>`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
</head>
<body>
    <h1>Login Page</h1>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
</head>
<body>
    <div>
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660028345662/dVNoPEZeA.png align="left")

> 'Login Page' and 'Enter your ID and password' are in a big box. To make the box visible, you need to name it first.

- Name the box and change its style.

```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```

- Change the color of mytitle to green by using `background: green;`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029227347/lnAvin6-8.png align="left")

- Change the size of the green box by using `width: / height:`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;
            
            width: 300px;
            height: 200px;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029245525/dT2YLcudD.png align="left")

- Change the text in the box to white by using `color: white;`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029268701/fglWoNBrP.png align="left")

- Align the text in the box to the center by using `text-align: center;`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;
            
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029291323/xwS8PWp2h.png align="left")


- Change the background to an image by using `background-image: URL("");`

`Tips: When adding an image as a background, always think about these three codes below`
- background-image: url("")
- background-size:
- background-position:

Image URL
; `https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg`

```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029318553/nOCscGX1Y.png align="left")


**It does not show the proper image!**
> it's because the image is too big for the box size. To solve this, you need to adjust the size of the box.

- Add `background-size: cover;`

```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029346195/7webzuz61.png align="left")


- Move the image to the center by using `background-position: center;`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029412828/ZZ3GcU0oZ.png align="left")


- Make the border round by using `border-radius:`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;
            
            border-radius: 10px;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660029572679/eVEDgJOOm.png align="left")

- To add margin **inside of the box** you need to use `padding` not `margin`

> Tip: `margin` is for **outside of a box**. 
`margin: 20px` means add 20px of margin all sides and it is the same as `margin: 20px(T) 20px(R) 20px(B) 20px(L)`

```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;

            border-radius: 10px;
            
            padding-top: 40px;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660030796886/fXQg1itr_.png align="left")

- How to move the box to the center of the page?
> it means having the same margin at the left and right sides.

> If you use `margin: 0px auto 0px auto;` only the box will move, so you need to group(`<div>`) the objects first.
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;

            border-radius: 10px;

            padding-top: 40px;
        }
    </style>
</head>
<body>
    <div class="mytitle">
        <h1>Login Page</h1>
        <h5>Enter your ID and password</h5>
    </div>
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <button> Login</button>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660031158982/qqX9EG5NH.png align="left")


- Group all the objects you want to move by using `<div>`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;

            border-radius: 10px;

            padding-top: 40px;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>Login Page</h1>
            <h5>Enter your ID and password</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <button> Login</button>
    </div>
</body>
</html>
```

- To see the area, change `wrap` to green.
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            background: green;

            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;

            border-radius: 10px;

            padding-top: 40px;
        }
        .wrap {
            background-color: green;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>Login Page</h1>
            <h5>Enter your ID and password</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <button> Login</button>
    </div>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660031429844/jKre1T0ds.png align="left")


> Now you can delete `background color: green` under `mytitle.

- We cannot add more margin to the left or right since the box is taking up the whole space. So the width needs to be adjusted by using `width: 300px`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;

            border-radius: 10px;

            padding-top: 40px;

        }
        .wrap {
            background-color: green;

            width: 300px;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>Login Page</h1>
            <h5>Enter your ID and password</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <button> Login</button>
    </div>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660031516155/eCESI8okI.png align="left")


- Add `margin: auto`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;

            border-radius: 10px;

            padding-top: 40px;

        }
        .wrap {
            background-color: green;

            width: 300px;

            margin: auto;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>Login Page</h1>
            <h5>Enter your ID and password</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <button> Login</button>
    </div>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660031572736/C9HUljfWy1.png align="left")

- Delete `backgroun color: green`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <style>
        .mytitle {
            width: 300px;
            height: 200px;

            color: white;

            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;

            border-radius: 10px;

            padding-top: 40px;

        }
        .wrap {
            width: 300px;

            margin: auto;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>Login Page</h1>
            <h5>Enter your ID and password</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <button> Login</button>
    </div>
</body>
</html>
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660031618826/8MdNYId-U.png align="left")






