HTML describes a web page with tags. A tag is a word in angle brackets, like <p>. Most come in pairs — an opening tag <p> and a closing tag </p> wrap some content. A tag plus its content is an element.
<p>Hello, world!</p>
<p>This is my first web page.</p>
The browser draws whatever is between the tags.
A tag you forget to close, or spell wrong, may not show correctly.
One element = opening tag + content + closing tag
1.2
제목 및 단락
헤딩은 여섯 가지 수준을 표시하며, <h1>(최상위)부터 <h6>(최하위)까지이며, CSS가 크기를 제어합니다. 문단(paragraph)은 <p>입니다. 페이지의 주요 제목에는 정확히 하나의 <h1>을 사용하십시오.
<h1>My Blog</h1>
<h2>About me</h2>
<p>I am learning to build web pages.</p>
1.3
텍스트 서식 지정
중요성(보통 굵게)에는 <strong>을, 강조 강조(보통 기울임체)에는 <em>을 사용하십시오. CSS가 외관을 변경할 수 있습니다. 줄 바꿈(line break)은 <br> — 닫는 태그가 없습니다.
<p><strong>Warning:</strong> read this carefully.</p>
<p>First line<br>second line</p>
<p>You can <em>emphasise</em> any word.</p>
Common mistakes
대부분의 요소는 열림 및 닫힘 태그를 사용합니다. 잘못된 중첩(bad nesting)은 브라우저가 예상치 못한 방식으로 문서를 수리하게 만들 수 있습니다.
The tag goes in angle brackets; the text you see goes between the opening and closing tags.
제목은 1(<h1>)부터 6(<h6>)까지 지정합니다. 크기만으로 제목을 선택하지 마십시오.
A link is an anchor <a>. Its href attribute holds the address it points to.
<a href="https://example.com">Visit Example</a>
<br>
<a href="page2.html">Go to the next page</a>
Add target="_blank" to open the link in a new tab.
2.3
이미지
An image is <img> — it has no closing tag. src is the picture's address; alt is text shown if the image cannot load (and read aloud to blind users).
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Bitmap_VS_SVG.svg/120px-Bitmap_VS_SVG.svg.png"
alt="bitmap versus vector" width="120">
<p>If the picture is missing, the alt text shows instead.</p>
Common mistakes
정보 제공 이미지는 의미를 전달하는 대체 텍스트가 필요합니다. 순수 장식용 이미지는 alt=""를 사용합니다. alt를 생략하는 것과 다릅니다. 링크에는 href가 필요합니다.
<img>는 별도의 종료 태그가 없습니다.
broken src path는 이미지 대신 대체 텍스트를 표시할 수 있습니다 — 파일명 및 폴더를 확인하십시오.
A <div> is a generic block box that groups content on its own lines. A <span> is a generic inline box inside a line of text. You use them to group things so you can style or position them.
Semantic tags describe their role, which helps screen readers and search engines. Prefer them over plain <div> where they fit: <header>, <nav>, <main>, <section>, <article>, <footer>.
CSS 스타일이 HTML을 스타일링한다. 가장 간단한 방법은 <style> 블록을 <head>에 넣는 것이며(더 큰 사이트는 별도의 .css 파일을 사용하여 <link>를 적용한다). CSS 규칙은 선택자(selector)와 그 다음 declarations라고 불리는 { property: value; } 쌍으로 구성된다.
<style>
p { color: blue; font-size: 18px; }
h1 { color: darkred; }
</style>
<h1>Styled heading</h1>
<p>This paragraph is blue.</p>
Link a stylesheet so CSS rules style HTML elements
6.2
셀렉터: class 및 id
한 class가 여러 요소를 스타일링할 때: HTML에 class="..."를 추가하고 CSS에 .name를 작성한다. id는 ONE 요소만 스타일링한다: id="..."와 #name.
기타 유용한 가상 클래스: :focus(초점을 가진 요소, 예: Tab 또는 클릭 후) 및 :first-child.
:hover 포인터가 요소 위에 있을 때 요소를 스타일링
10.2
배치(Positioning)
포지셔닝은 박스를 정상 위치에서 이동시킵니다. relative는 박스(및 자식 요소의 기준점)를 미세 조정하고; absolute은 가장 가까운 포지셔닝된 조상 요소를 기준으로 박스를 정확히 배치하며; fixed은 페이지 스크롤 시 일반적으로 뷰포트에 고정됩니다. 변환된 조상 요소가 대신 containing block을 생성할 수 있습니다.
top, right, bottom, left은 이동 거리를 지정합니다 — 배치된 상자에서만 작동합니다.
10.3
미디어 쿼리 및 반응형 디자인
반응형 페이지는 화면 크기에 맞춰 조정됩니다. 미디어 쿼리는 화면에 대한 특정 조건(예: max-width)이 성립할 때만 규칙을 적용합니다.
<style>
.banner { background: #2563eb; color: white; padding: 16px; }
@media (max-width: 600px) {
.banner { background: #16a34a; } /* narrow screens turn green */
}
</style>
<div class="banner">Resize the window: blue when wide, green when narrow.</div>
모바일 피스 트를 설계하십시오: 먼저 휴대폰 스타일을 작성한 후 더 큰 화면을 위한 @media (min-width: ...) 규칙을 추가하십시오.
백분율 너비와 max-width은 상자가 화면에 따라 축소되게 합니다.
Common mistakes
:hover는 선택자와 공백 없이 결합됩니다: .btn:hover, .btn :hover가 아닙니다.
position: absolute는 가장 가까운 포지셔닝된 조상 요소를 기준으로 측정되므로, 의도하는 containing 조상 요소인 position: relative을 명시해야 합니다. containing 조상 요소가 없으면 초기 containing block이 사용됩니다.
미디어 쿼리는 전체 규칙을 감쌉니다: @media (max-width: 600px) { .a { ... } }.