Creating HTML Tables Step-by-Step
HTML tables are created with the <table>
element:
<table class="table table-bordered">
<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>
Common table elements:
<tr>
- Table row<td>
- Table data cell<th>
- Table header cell<caption>
- Table title
Creating Ordered, Unordered, and Description Lists
Unordered List
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
Ordered List
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
Description List
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
</dl>
Using Code and Preformatted Text in HTML
For displaying code:
<code>const x = 10;</code> // For inline code
<pre> // For code blocks
function example() {
return "Hello";
}
</pre>
Combine with <samp>
for sample output and <kbd>
for keyboard input.
HTML Entities and Special Characters
Common HTML entities:
Character | Entity | Description |
---|---|---|
< | < | Less than |
> | > | Greater than |
& | & | Ampersand |
ยฉ | © | Copyright |
Adding Emojis to Your Web Page
Three ways to add emojis:
- Directly paste emoji: ๐
- Use HTML decimal code:
😊
(๐) - Use HTML hex code:
😊
(๐)
Ensure your document uses UTF-8 encoding:
<meta charset="UTF-8">
Using HTML Symbols
Common symbol entities:
♥
โฅ Heart♠
โ Spade♣
โฃ Club
♦
โฆ Diamond™
โข Trademark€
โฌ Euro
Character Sets and Encoding
Essential character encoding declarations:
<meta charset="UTF-8"> // HTML5
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> // Legacy
Common character sets:
- UTF-8 - Unicode (recommended)
- ISO-8859-1 - Latin alphabet
- Windows-1252 - Western European
HTML URL Encoding Explained
URLs can only contain certain characters. Others must be encoded:
https://example.com/search?q=HTML%20Basics
Common URL encodings:
Character | Encoding |
---|---|
Space | %20 |
! | %21 |
# | %23 |
HTML vs XHTML โ What's the Difference?
Feature | HTML | XHTML |
---|---|---|
Document Type | text/html | application/xhtml+xml |
Case Sensitivity | Case insensitive | Case sensitive |
Tag Closing | Optional for some | Required for all |
Attribute Quotes | Optional | Required |
Modern web development typically uses HTML5.