HTML 테이블에는 데이터를 삽입, 정렬, 표시할 수 있는 여러 행과 열이 있습니다. 이 데이터는 웹 페이지에 표 형식으로 표시됩니다. 이러한 테이블은 항목 목록 표시, 판매 보고서와 같은 표 형식 데이터 표시, 웹 페이지 섹션 레이아웃 생성 등과 같이 데이터를 순서대로 표시하는 데 도움이 됩니다.
이 기사에서는 다음 유형의 HTML 테이블을 만드는 방법을 알아봅니다.
- 간단한 테이블
- 테두리와 패딩이 있는 표
- 스타일링이 적용된 테이블
- 캡션이 포함된 표
- 중첩 테이블이 있는 테이블
- 열 범위와 행 범위가 있는 테이블
- colgroup이 포함된 테이블
HTML로 테이블을 생성하기 위한 필수 사항
- 텍스트 편집기 또는 HTML 편집기: Notepad++, Sublime Text 또는 Visual Studio Code와 같은 텍스트 편집기 또는 HTML 편집기를 열어 HTML 코드를 작성하고 저장합니다. 기본 편집기로 Notepad++를 사용했지만 원하는 편집기를 사용해도 됩니다.
- HTML 파일: Notepad++에서 새 파일을 만듭니다. 이름을 "table.html" 또는 원하는 다른 이름으로 지정하겠습니다. 단, 파일 이름은 ".html"로 끝나야 합니다. 이 파일은 웹페이지에 대한 코드를 작성하는 곳입니다. 이 파일을 만드는 데 도움이 필요하면 "HTML로 웹 페이지 디자인" 튜토리얼을 확인하세요.
- HTML 코드: 이 문서에서는 다양한 유형의 테이블을 생성하는 데 필요한 모든 필수 코드를 제공했습니다. 코드를 복사하여 “table.html” 파일에 붙여넣기만 하면 됩니다.
- 웹 브라우저: “table.html” 파일에 HTML 코드 작성을 마친 후 웹페이지를 보고 테스트해야 합니다. Google Chrome, Mozilla Firefox 또는 Microsoft Edge와 같은 웹 브라우저를 사용할 수 있습니다. 이 기사의 모든 예에 대한 웹페이지를 보기 위해 Google Chrome을 사용했지만 원하는 브라우저를 선택할 수 있습니다.
HTML에서 사용되는 태그
HTML로 테이블을 만들기 전에 테이블을 만들고 구성하는 데 사용되는 태그를 이해하는 것이 중요합니다. HTML 테이블을 생성하는 데 사용되는 주요 태그는 다음과 같습니다.
Tag | Description | |||||||||||||||||||||
|
설명 | |||||||||||||||||||||
테이블과 그 내용을 정의합니다. | ||||||||||||||||||||||
표의 제목이나 캡션을 정의합니다. | ||||||||||||||||||||||
표의 헤더 내용을 그룹화합니다. | ||||||||||||||||||||||
본문 내용을 표로 그룹화합니다. | ||||||||||||||||||||||
테이블의 바닥글 콘텐츠를 그룹화합니다. | ||||||||||||||||||||||
표 행을 정의합니다. | ||||||||||||||||||||||
번째> | 표 헤더 셀을 정의합니다. | |||||||||||||||||||||
테이블 데이터/셀을 정의합니다. | ||||||||||||||||||||||
형식 지정을 위해 테이블에서 하나 이상의 열 집합을 지정합니다. | ||||||||||||||||||||||
테이블의 열 그룹에 대한 속성을 정의합니다. |
Examples of Tables in HTML
Example 1: Simple Table
Let’s create a basic HTML table that showcases product information. We will include two columns labeled “Product” and “Price.” The table will contain a single row displaying data for the product “Apple” with a price of $20.
To create a simple HTML table:
- Open an HTML file in a text or HTML editor.
- Add the
element to define the table.
- Use the
element to create table rows. - The
element defines table headers (column labels). - Use the
element to create table cells (data). - Insert the desired data within the table cells.
- Save the file with the .html extension, and then open it in a web browser to view the table.
Code:
<title>Simple Table</title>
Product Price Apple $20 Output:
The resultant table for product and price will be displayed as seen below:
To add an additional column to the table in the example, you can use the
element within your table’s column. This element is used to define header cells for the column. And if you want to add a new row to the table, you can use the
element. This element is used to define regular cells within the table row. Code:
Product Price Quantity Apple $20 10 Orange $10 15 Output:
Let’s see how to add borders to an HTML table. This is a way to visually separate the different sections of the table and make it easier to read and understand.
Example 2: Table with Borders and Padding
In this example, we will add a table element and set the border and cellpadding attribute. We will use the border attribute and set the width of the table’s border to 1 pixel. For the cellpadding attribute, we will use 5 pixels of padding for the content inside each cell.
Code:
Name Age Country Michael 27 Alaska Evelyn 32 Ohio Output:
Example 3: Table with Styling
If you want to improve the appearance of your table, you can use CSS (Cascading Style Sheets) to add various styles and formatting.
One way to enhance the table is by giving different cells a background color. To do this, you can simply add the style attribute with the background-color property inside the opening
tag. For instance, you can use style=”background-color: #33cccc;” to set the background color to a nice shade of teal. Code:
Country Population Capital Spain 47 Million Madrid Finland 5.5 Million Helsinki Output:
Example 4: Table with Caption
Using an HTML table with a caption is a great way to present information on a webpage in a tidy and organized manner. It’s like giving your table a title or a brief description to help people grasp its content easily. To include a caption, all you have to do is use the
tag and place it right below the tag.
Code:
<style> table { border-collapse: collapse; } th, td { border: 1px solid black; padding: 8px; } caption { background-color: #33cccc; padding: 8px; font-weight: bold; } </style>
Employee Information Name Position Salary Margot Mitchell Manager $60,000 Ryan Arnett Developer $50,000 Output:
Example 5: Table with Nested Tables
In HTML, when we talk about a nested table, it means we have a table placed inside another table. So, basically, some cells in the outer table contain a whole new table structure within them. If you want to include a nested table, you just need to insert another table inside any cell of your main table. To understand better, here is an example:
Code:
Device Brand Specifications Smartphone Apple Model Storage iPhone 12 Pro 256GB iPhone SE 128GB Laptop HP 15.6" Display Tablet Samsung 10.5" Display Output:
Example 6: Table with Col Span and Row Span
In HTML, the “colspan” and “rowspan” give you the power to merge or split cells horizontally (colspan) and vertically (rowspan) to create more advanced table structures.
If you want to merge cells horizontally, simply use “colspan” followed by the number of cells you want to merge. And if you want to merge cells vertically, you can use “rowspan” along with the number of cells you want to merge.
To use the colspan and rowspan attributes, you can add them directly within the
or elements that you want to merge. Code:
<style> table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid black; padding: 8px; text-align: left; } .football { background-color: #33cccc; } .tennis { background-color: #33cccc; } .lebron { background-color: #fddb5d; } .heading { background-color: #808080; /* Grey */ color: #fff; /* White */ } </style>
Sport Player Football Lionel Messi Cristiano Ronaldo Neymar Harry Kane Tennis Novak Djokovic Rafael Nadal Serena Williams Naomi Osaka Basketball LeBron James Output:
Example 7: Table with Colgroup
In HTML, we use the
element to group columns in an HTML table. We can also use the tag within the tag to set a background color for specific columns. To implement this, you can simply add a right after the opening tag.
Code:
<style> table { border-collapse: collapse; } th, td { border: 1px solid black; padding: 8px; } </style>
City Country Continent New York United States North America London United Kingdom Europe Tokyo Japan Asia Output:
- Use the
위 내용은 HTML로 테이블 만들기의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

HTML의 미래 트렌드는 의미론 및 웹 구성 요소이며 CSS의 미래 트렌드는 CSS-In-JS 및 CSShoudini이며, JavaScript의 미래 트렌드는 WebAssembly 및 서버리스입니다. 1. HTML 시맨틱은 접근성과 SEO 효과를 향상시키고 웹 구성 요소는 개발 효율성을 향상 시키지만 브라우저 호환성에주의를 기울여야합니다. 2. CSS-in-JS는 스타일 관리 유연성을 향상 시키지만 파일 크기를 증가시킬 수 있습니다. CSShoudini는 CSS 렌더링의 직접 작동을 허용합니다. 3. Webosembly는 브라우저 애플리케이션 성능을 최적화하지만 가파른 학습 곡선을 가지고 있으며 서버리스는 개발을 단순화하지만 콜드 스타트 문제의 최적화가 필요합니다.

웹 개발에서 HTML, CSS 및 JavaScript의 역할은 다음과 같습니다. 1. HTML은 웹 페이지 구조를 정의하고, 2. CSS는 웹 페이지 스타일을 제어하고 3. JavaScript는 동적 동작을 추가합니다. 그들은 함께 현대 웹 사이트의 프레임 워크, 미학 및 상호 작용을 구축합니다.

HTML의 미래는 무한한 가능성으로 가득합니다. 1) 새로운 기능과 표준에는 더 많은 의미 론적 태그와 WebComponents의 인기가 포함됩니다. 2) 웹 디자인 트렌드는 반응적이고 접근 가능한 디자인을 향해 계속 발전 할 것입니다. 3) 성능 최적화는 반응 형 이미지 로딩 및 게으른로드 기술을 통해 사용자 경험을 향상시킬 것입니다.

웹 개발에서 HTML, CSS 및 JavaScript의 역할은 다음과 같습니다. HTML은 컨텐츠 구조를 담당하고 CSS는 스타일을 담당하며 JavaScript는 동적 동작을 담당합니다. 1. HTML은 태그를 통해 웹 페이지 구조와 컨텐츠를 정의하여 의미를 보장합니다. 2. CSS는 선택기와 속성을 통해 웹 페이지 스타일을 제어하여 아름답고 읽기 쉽게 만듭니다. 3. JavaScript는 스크립트를 통해 웹 페이지 동작을 제어하여 동적 및 대화식 기능을 달성합니다.

Htmlisnotaprogramminglanguage; itisamarkuplanguage.1) htmlstructuresandformatswebcontentusingtags.2) itworksporstylingandjavaScriptOfforIncincivity, WebDevelopment 향상.

HTML은 웹 페이지 구조를 구축하는 초석입니다. 1. HTML은 컨텐츠 구조와 의미론 및 사용 등을 정의합니다. 태그. 2. SEO 효과를 향상시키기 위해 시맨틱 마커 등을 제공합니다. 3. 태그를 통한 사용자 상호 작용을 실현하려면 형식 검증에주의를 기울이십시오. 4. 자바 스크립트와 결합하여 동적 효과를 달성하기 위해 고급 요소를 사용하십시오. 5. 일반적인 오류에는 탈수 된 레이블과 인용되지 않은 속성 값이 포함되며 검증 도구가 필요합니다. 6. 최적화 전략에는 HTTP 요청 감소, HTML 압축, 시맨틱 태그 사용 등이 포함됩니다.

HTML은 웹 페이지를 작성하는 데 사용되는 언어로, 태그 및 속성을 통해 웹 페이지 구조 및 컨텐츠를 정의합니다. 1) HTML과 같은 태그를 통해 문서 구조를 구성합니다. 2) 브라우저는 HTML을 구문 분석하여 DOM을 빌드하고 웹 페이지를 렌더링합니다. 3) 멀티미디어 기능을 향상시키는 HTML5의 새로운 기능. 4) 일반적인 오류에는 탈수 된 레이블과 인용되지 않은 속성 값이 포함됩니다. 5) 최적화 제안에는 시맨틱 태그 사용 및 파일 크기 감소가 포함됩니다.

WebDevelopmentReliesonHtml, CSS 및 JavaScript : 1) HtmlStructuresContent, 2) CSSSTYLESIT, 및 3) JAVASCRIPTADDSINGINTERACTIVITY, BASISOFMODERNWEBEXPERIENCES를 형성합니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

SecList
SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구
