출처 : https://www.w3schools.com/html/html_intro.asp
HTML 이란?
예제
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<!DOCTYPE html> html 문서임을 명시
<html></html> html 영역
<head></head> html 의 보이지 않는 정보, 메타 정보가 담긴 영역
<title></title> 페이지의 제목, 타이틀
<body><body> 사용자에게 보여지는 영역
<h1> 은 큰 제목
<p> 는 텍스트 단락
HTML의 기본 구조
웹사이트 만들고 코드를 온라인에 저장하는 법
https://www.w3schools.com/spaces/
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<!DOCTYPE>
는 대소문자를 구분하지 않는다<h1> ~ <h6>
는 제목 태그<p>
태그는 단락 태그<a>
태그는 앵커 태그, href에 링크 주소를 넣으면 클릭시 그 주소로 이동한다<img>
태그는 이미지 태그, src로 이미지 주소를 넣는다. alt, width, height 속성<h1>
제목을 나타내는 태그<p>
단락을 나타내는 태그<br>
nextLine 태그, 이 태그는 닫는 태그가 없다.HTML 요소들은 속성을 가질 수 있다.
속성들은 요소들의 추가적인 정보를 제공하며, 시작 태그 안에 명시해주어야 한다.
속성들은 보통 이름과 값이 쌍을 이룬다. ex) name="value"
ex) <a href=="https://www.w3schools.com">Visit W3Schools</a>
<img src="img_girl.jpg">
<p style="color:red;">This is a red paragraph.</p>
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html>
Heading 태그
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<h1 style="font-size:60px;">Heading 1</h1>
<p>
태그는 단락을 의미한다.
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<p>
태그 안에서는 여분의 공백이나 줄을 추가해도 반영이 안 된다.
<hr>
는 수평선을 긋는 태그이다.<br>
는 줄을 추가하는 태그이다.<pre>
Element<pre>
태그를 사용하면 줄과 여분의 공백을 반영할 수 있다.Style 속성은 CSS 속성이다.
<!DOCTYPE html>
<html>
<body>
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>
</body>
</html>
<tagname style="property:value;">
<body style="background-color:powderblue;"> </body>
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
<b> - Bold text
<strong> - Important text
<i> - Italic text
<em> - Emphasized text
<mark> - Marked text
<small> - Smaller text
<del> - Deleted text
<ins> - Inserted text
<sub> - Subscript text
<sup> - Superscript text
<abbr>
약어를 정의하는 태그<address>
연락처 정보 (기울임꼴 + 줄바꿈)<bdo>
양방향 재정의 (텍스트 방향)<blockquote>
인용문 (들여쓰기)<cite>
작품 제목 (기울임꼴)<q>
짧은 인용글 (따옴표)<!-- Write your comments here -->
RGB, HEX, HSL, RGBA, HSLA 등의 방식으로 표현 가능하다. 컬러의 이름으로도 지정가능하다. A는 불투명도이다.
RGB = Red + Green + Blue
A = Alpha
Red + Green + Blue
RGB의 값을 16진수로 나타낸 것이다.
hsl(hue, saturation, lightness)
색상 + 채도 + 명도
CSS(Cascading Style Sheets) 는 웹 페이지의 레이아웃 형식을 지정한다. 색상, 글꼴, 텍스트 크기, 요소 사이의 간격, 위치 및 배치 방법 등 다양한 디스플레이 설정을 할 수 있다.
<style>
의 요소 사용<head>
<link>
외부 CSS 파일에 연결가장 일반적인 방법은 외부 요소를 사용하는 방법이다.
color텍스트 색상에 CSS 속성 사용
font-family텍스트 글꼴에 CSS 속성 사용
font-size텍스트 크기에 CSS 속성 사용
border테두리에 CSS 속성 사용
padding테두리 안의 공간에 CSS 속성 사용
margin테두리 밖의 공간에 CSS 속성 사용
<a href="url">link text</a>
_self- 기본. 클릭한 것과 동일한 창/탭에서 문서를 엽니다.
_blank- 새 창이나 탭에서 문서 열기
_parent- 상위 프레임에서 문서를 엽니다.
_top- 창 전체에서 문서를 엽니다.
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/">W3C</a></p>
<p><a href="https://www.google.com/">Google</a></p>
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>
<img>요소( 내부 )를 사용하여 <a>이미지를 링크로 사용
mailto:속성 내부의 체계를 사용하여 href사용자의 이메일 프로그램을 여는 링크를 만듭니다.
<a>
태그의 색상 설정<style>
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
</style>
<a>
태그 button 처럼 만들기<style>
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
</style>
id 값을 이용해서 특정 태그로 이동하게 할 수 있다.
<a>
태그를 클릭하면 C4인 <h2>
태그로 이동한다. (자동 스크롤))<a href="#C4">Jump to Chapter 4</a>
~~~
<h2 id="C4">Chapter 4</h2>
<img>
태그를 이용해서 웹 페이지에 이미지를 삽입할 수 있다.
<img src="pic_trulli.jpg" alt="Italian Trulli">
src는 주소를, alt는 대체 텍스트를 나타낸다.
width, height로 가로 세로 크기를 지정할 수 있고, CSS를 통해서도 지정가능하다.
float 속성으로 이미지를 왼쪽이나 오른쪽으로 띄울 수 있다.
maps를 사용해서 이미지의 특정 부분만 클릭할 수 있도록 할 수 있다.
<img src="workplace.jpg" alt="Workplace" usemap="#workmap">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
<area shape="circle" coords="337,300,44" alt="Coffee" href="coffee.htm">
</map>
usemap 속성을 <img>
태그 내에 추가해야한다.
rect- 직사각형 영역을 정의합니다. (죄측상단의 x,y 우측하단의 x,y)
circle- 원형 영역을 정의합니다. (중심좌표 x,y 반지름)
poly- 다각형 영역을 정의합니다. (여러 점의 x,y 좌표를 나열)
<area shape="poly" coords="140,121,181,116,204,160,204,222,191,270,140,329,85,355,58,352,37,322,40,259,103,161,128,147" href="croissant.htm">
default- 전체 지역을 정의합니다.
위의 방법으로 클릭 가능한 영역을 잡은 뒤 JavaScript 함수 이벤트를 추가할 수 있다.
<p style="background-image: url('img_girl.jpg');">
<style>
body {
background-image: url('img_girl.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
<picture>
Element<picture>
<source media="(min-width: 650px)" srcset="img_food.jpg">
<source media="(min-width: 465px)" srcset="img_car.jpg">
<img src="img_girl.jpg">
</picture>
<picture>
태그의 사용 목적<picture>
태그를 사용하면, 브라우저는 속성 값과 일치하는 첫 번째 <source>
요소를 사용하고, 다음 요소들은 무시한다.<picture>
태그를 사용하여 모든 형식의 이미지를 추가할 수 있다. 브라우저는 첫 번째 형식을 인지하며 다음 요소들은 모두 무시한다.브라우저의 타이틀 옆에 있는 작은 아이콘
<!DOCTYPE html>
<html>
<head>
<title>My Page Title</title>
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<title>
태그 옆에 <link>
태그를 달아서 페이지 아이콘을 추가할 수 있다.
<title>HTML Tutorial</title>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
<tr>
태그는 행을, <td>
태그는 열을 나타낸다.
<th>
태그를 사용하면 테이블의 제목을 표시할 수 있다.
css로 테이블의 경계를 수정할 수 있다.
https://www.w3schools.com/html/html_table_borders.asp
css 속성을 사용하여 테이블의 크기를 변경할 수 있다.
https://www.w3schools.com/html/html_table_sizes.asp
테이블 헤더의 다양한 표시 방법
https://www.w3schools.com/html/html_table_headers.asp
테이블 태그 border의 두께를 지정할 수 있다.
https://www.w3schools.com/html/html_table_padding_spacing.asp
테이블 태그의 열과 행의 일부를 합칠 수 있다. (행/열 합치기)
https://www.w3schools.com/html/html_table_colspan_rowspan.asp
테이블의 스타일 변경하기
https://www.w3schools.com/html/html_table_styling.asp
테이블의 일부(열 단위)의 속성을 변경하고 싶은 경우, colgroup으로 묶을 수 있다.
<table>
<colgroup>
<col span="2" style="background-color: #D6EEEE">
</colgroup>
<tr>
<th>MON</th>
<th>TUE</th>
<th>WED</th>
<th>THU</th>
...
https://www.w3schools.com/html/html_table_colgroup.asp
<ul> <li></li> </ul>
<ol> <li></li> </ol>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>