HTML에서 테이블을 만들려면 여러 특정 태그를 사용해야합니다. 다음은 기본 테이블을 만들고 다른 테이블 태그를 이해하기위한 단계별 안내서입니다.
다음은 기본 HTML 테이블의 예입니다.
<code class="html"><table> <thead> <tr> <th>Header 1</th> <th>Header 2</th> </tr> </thead> <tbody> <tr> <td>Row 1, Cell 1</td> <td>Row 1, Cell 2</td> </tr> <tr> <td>Row 2, Cell 1</td> <td>Row 2, Cell 2</td> </tr> </tbody> </table></code>
테이블이 올바르게 표시되도록 HTML의 중첩 테이블 요소에 대한 올바른 구조는 필수적입니다. 계층 구조와 올바른 중첩 순서는 다음과 같습니다.
올바른 중첩의 예 :
<code class="html"><table> <thead> <tr> <th>Header 1</th> <th>Header 2</th> </tr> </thead> <tbody> <tr> <td>Row 1, Cell 1</td> <td>Row 1, Cell 2</td> </tr> </tbody> </table></code>
HTML 테이블 스타일링은 시각적 매력과 가독성을 크게 향상시킬 수 있습니다. CSS를 사용하여이를 달성 할 수 있습니다. 다음은 몇 가지 기술입니다.
<code class="css">table, th, td { border: 1px solid black; border-collapse: collapse; }</code>
<code class="css">th { background-color: #f2f2f2; } tr:nth-child(even) { background-color: #f9f9f9; }</code>
<code class="css">th, td { padding: 10px; }</code>
<code class="css">th { text-align: left; }</code>
<code class="css">table { width: 100%; } th, td { height: 30px; }</code>
다음은 스타일 테이블의 예입니다.
<code class="html"><style> table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 10px; } th { background-color: #f2f2f2; text-align: left; } tr:nth-child(even) { background-color: #f9f9f9; } </style> <table> <thead> <tr> <th>Header 1</th> <th>Header 2</th> </tr> </thead> <tbody> <tr> <td>Row 1, Cell 1</td> <td>Row 1, Cell 2</td> </tr> <tr> <td>Row 2, Cell 1</td> <td>Row 2, Cell 2</td> </tr> </tbody> </table></code>
예: 예: 요약하면 (테이블 헤더) :
내 텍스트는 대담하고 중앙에 있습니다.
<code class="html"><table> <tr> <th>Name</th> <th>Age</th> </tr> </table></code>
(테이블 데이터) :
내의 텍스트는 규칙적이며 왼쪽에 정렬됩니다.
<code class="html"><table> <tr> <td>John Doe</td> <td>30</td> </tr> </table></code>
를 사용하여 헤더를 사용하여 컨텍스트와 구조를 제공하고 테이블 내 실제 데이터에
를 사용하십시오. 이 차이는 시각적 및 접근성 목적 모두에 중요합니다.
위 내용은 HTML에서 테이블을 어떻게 만드나요? 다른 테이블 태그는 무엇입니까 (예 : & lt; table & gt;, & lt; tr & gt;, & lt; td & gt;, & lt; th & gt;)?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!