Entities and Code Tags¶
1. HTML Entities¶
HTML Entities are used to display reserved characters that would otherwise be interpreted as HTML.
Common Entities:¶
Character | Entity Code | Description |
---|---|---|
< |
< |
Less than |
> |
> |
Greater than |
& |
& |
Ampersand |
" |
" |
Double quote |
' |
' |
Single quote |
|
|
Non-breaking space |
Example:¶
<p>5 < 10 && 10 > 5</p>
Output:¶
5 < 10 && 10 > 5
2. <code>
— Inline Code¶
- Displays a short snippet of code
- Renders using a monospaced font
- Usually used inside paragraphs
<p>Use the <code><section></code> tag for grouping content.</p>
Output:¶
Use the
<section>
tag for grouping content.
3. <pre>
— Preformatted Text¶
- Preserves whitespace, tabs, and line breaks
- Often used to display blocks of code
<pre>
function greet(name) {
console.log("Hello, " + name);
}
</pre>
Output:¶
function greet(name) { console.log("Hello, " + name); }
4. <kbd>
— Keyboard Input¶
- Used to show what the user should type
- Usually renders in a monospace font
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.</p>
Output:¶
Press Ctrl + C to copy.
5. <samp>
— Sample Output¶
- Represents sample output from a program
<p>Output: <samp>Hello, World!</samp></p>
Output:¶
Output: Hello, World!
6. <var>
— Variable Name¶
- Used to represent a variable in programming or math
<p>The value of <var>x</var> is 10.</p>
Output:¶
The value of x is 10.