Intro
HTML Learning Part One - Basics: https://blog.yexca.net/archives/146 HTML Learning Part Two - Lists, Tables, and Forms: https://blog.yexca.net/archives/150 HTML Learning Part Three - Web Page Layout: https://blog.yexca.net/archives/195
Basic Structure
| |
Usually generated by software. For example, in VS Code, create a new .html file, type ! then hit TAB to auto-generate.
The head tag is generally for the browser, while the body tag is for users.
Comments
| |
In VS Code, select a line and use Ctrl + / to toggle comments.
Browsers won’t display comment content.
Headings and Paragraphs
| |
Heading tags display bold text and take up a full line.
Paragraph tags take up a full line, with spacing between paragraphs.
Line Breaks and Horizontal Rules
Line breaks within paragraph tags won’t render visually. Use a line break tag if you need one.
| |
Here’s the horizontal rule tag:
| |
Looks like this:
Text Formatting Tags
| Effect | Tag Name | Abbr. |
|---|---|---|
| Bold | strong | b |
| Italic | em | i |
| Underline | ins | u |
| del | s |
Generally, abbreviations aren’t recommended. Here’s an example:
| |
Looks like this:
Hello, I'm yexca. Welcome to this blogWhat should I write next?
Image Tag
The image tag requires you to specify the image’s location in the src attribute.
| |
Paths can be absolute or relative. Let’s say your current path (on Linux) is:
| |
If the code is in index.html, the relative path is:
| |
The absolute path is:
| |
Hyperlink Tag
| |
This tag creates links to other web pages. To open a page in a new window, just set the target attribute to _blank. For instance:
| |
Looks like this:
Jump to
yexca
This opens in a new tab: yexca
Audio/Video Tags
| |
Here are the audio tag attributes:
| Attribute | Function | Description |
|---|---|---|
| src | Audio path | Required attribute, supports mp3, ogg, wav |
| controls | Displays audio controls | |
| loop | Loops playback | |
| autoplay | Autoplays | Browsers usually block autoplay |
Here are the video tag attributes:
| Attribute | Function | Description |
|---|---|---|
| src | Video path | Required attribute, supports mp4, webm, ogg |
| controls | Displays video controls | |
| loop | Loops playback | |
| muted | Plays silently | |
| autoplay | Autoplays | Browsers support autoplay when muted |
Suppose your current path is:
| |
For example, this code:
| |
Layout Tags
These tags don’t have inherent semantic meaning but are used for page layout, dividing areas, or placing content.
- div: Takes up a full line
- span: Does not break line
For example, this code:
| |
Looks like this:
Used to display reserved characters on a webpage, like spaces, < or >.
| Result | Description | Entity Name | Entity Number |
|---|---|---|---|
| non-breaking | space | |   |
| < | less than | < | < |
| > | greater than | > | > |
| & | ampersand | & | & |
| “ | double quotation mark | " | " |
| ‘ | single quotation mark (apostrophe) | ' | ' |
| ¢ | cent | ¢ | ¢ |
| £ | pound | £ | £ |
| ¥ | yen | ¥ | ¥ |
| € | euro | € | € |
| © | copyright | © | © |
| ® | registered trademark | ® | ® |
For example, to display <p>:
| |
Reference: Differences between HTML Character Entities &Nbsp; &Ensp; &Emsp;