HTML, CSS 기본내용

송수용·2022년 4월 2일
0

웹 개발 종합반

목록 보기
3/24

HTML과 CSS 개념이해하기

HTML은 뼈대, CSS는 꾸미기!

인스타그램에서 니꼴라스가 HTML과 CSS의 비유를 기가 막히게 들었던 기억이 있다.
HTML은 민낯이고, CSS는 화장! 정말 적절한 비유인 것 같다.
(나는 이런 비유를 좋아한다.)

HTML은 크게 head와 body로 나뉜다.
head안에는 페이지의 속성 정보를 담고, body안에는 내용을 담는다.
head안에는 meta, script, link,title 등 있다.

body안에 들어가는 대표적인 요소들!

<body>
<!-- 구역을 나누는 태그들 -->
<div>나는 구역을 나누죠</div>
<p>나는 문단이에요</p>
<ul>
<li> bullet point!1 </li>
<li> bullet point!2 </li>
</ul>
<!-- 구역 내 콘텐츠 태그들 -->
<h1>h1은 제목을 나타내는 태그입니다. 페이지마다 하나씩 꼭 써주는 게 좋아요. 그래야 구글 검색이 잘 되거든요.</h1>
<h2>h2는 소제목입니다.</h2>
<h3>h3~h6도 각자의 역할이 있죠. 비중은 작지만..</h3>
<hr>
span 태그입니다: 특정 <span style="color:red">글자</span>를 꾸밀 때 써요
<hr>
a 태그입니다: <a href="http://naver.com/"> 하이퍼링크 </a>
<hr>
img 태그입니다: <img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" />
<hr>
input 태그입니다: <input type="text" />
<hr>
button 태그입니다: <button> 버튼입니다</button>
<hr>
textarea 태그입니다: <textarea>나는 무엇일까요?</textarea>

간단한 로그인 페이지 만들기

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>로그인페이지</title>
</head>
<body>
	<h1>로그인 페이지</h1>
	<p>ID: <input type="text"/></p>
	<p>PW: <input type="text"/></p>
<button>로그인하기</button>
</body>
</html>

CSS기초

배경관련
background-color
background-image
background-size

사이즈
width
height

폰트
font-size
font-weight
font-famliy
color

간격
margin = 바깥 여백 조정
padding = 안쪽 여백 조정

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>스파르타코딩클럽 | 로그인페이지</title>
<style>
  .mytitle {
  color: white;
  width: 300px;
  height: 200px;
  background-image: url('https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg');
  background-position: center;
  background-size: cover;
  border-radius: 10px;
  text-align: center;
  padding-top: 40px;
}
</style>
</head>
<body>
<div class="mytitle">
  	<h1>로그인 페이지</h1>
  	<h5>아이디, 비밀번호를 입력해주세요</h5>
</div>
<div>
	<p>ID: <input type="text" /></p>
	<p>PW: <input type="password" /></p>
</div>
<button>로그인하기</button>
</body>
</html>

body안에 있는 div class ="mytitle" 에서 style로 css를 줄 경우 .mytitle 로 .을 쓴다.
만약 div id = mytitle 일 경우는 #을 사용한다.

완성본

완성본 코드

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>로그인페이지</title>
    <link href="https://fonts.googleapis.com/css2?family=Jua&display=swap" rel="stylesheet">
</head>
<style>
    * {
        font-family: 'Jua', sans-serif;
    }
    .mytitle {
        background-color: 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: 10px;
    }

    .wrap {

        width: 300px;
        margin: auto;
    }
</style>
<body>
<div class="wrap">
    <div class="mytitle">
        <h1>로그인페이지</h1>
        <h5>아이디, 비밀번호를 입력해주세요.</h5>
    </div>
    <p>ID : <input type="text"/></p>
    <p>PW : <input type="text"/></p>
    <button class="mybutton">로그인 하기</button>
</div>
</body>
</html>
profile
#공부중 #협업 #소통중시 #백엔드개발자 #능동적 #워커홀릭 #스파르타코딩 #항해99 #미니튜터 #Nudge #ENTJ #브레인스토밍 #아이디어뱅크

0개의 댓글