HTML entities are special codes used to display reserved characters in HTML. They start with & and end with ;.
| Character | Entity Code | Output |
|---|---|---|
| < | < | < |
| > | > | > |
| & | & | & |
| “ | " | “ |
| ‘ | ' | ‘ |
LAMP is a stack of technologies used for web development:
Attributes provide additional information about HTML elements. They are written inside the opening tag.
<img src="image.jpg" alt="My Image" width="200">
Here, src, alt, and width are attributes.
Answer: A pixel (short for picture element) is the smallest unit of a digital image or screen. One pixel displays a single dot of color on the screen.
Web page width depends on screen resolution. Here are suggested widths:
Modern websites use responsive layouts instead of fixed widths.
<font width="200" height="100" color="green" size="2">This is my text</font>
Note: Font tag and attributes like width, height, and color are deprecated in HTML5. Use CSS instead.
Modern HTML separates content from styling. Use CSS for design:
<p style="color: green; font-size: 14px;">This is my text</p>
<img src="path/to/image.jpg" alt="Description of image">
Inline Elements: Do not start on a new line and only occupy as much width as needed. Examples: <span>, <a>, <strong>, <img>
Block Elements: Start on a new line and take the full width. Examples: <div>, <p>, <h1> to <h6>
<div><p>Text inside paragraph</p></div> <!-- ✅ Valid -->
<span><a href="#">Link</a></span> <!-- ✅ Valid -->
<span><div>Invalid</div></span> <!-- ❌ Invalid -->
<em>Important text</em> → Important text
<pre>Line 1
Line 2</pre>
<span style="color: red;">Red text</span> → Red text
The <img> tag is used to display images in HTML.
<img src="images/photo.jpg" alt="My Photo" title="Hover Text" width="200" height="150">
images/photo.jpg
https://example.com/images/photo.jpg
/ from root if working on server.../ to move one level up in folder hierarchy.../../images/bbc.jpg
Recommendation:
| Entity | Description | Rendered Output |
|---|---|---|
| | Non-breaking space | [ ] |
| & | Ampersand | & |
| < | Less-than sign | < |
| > | Greater-than sign | > |
| © | Copyright symbol | © |
| ® | Registered trademark | ® |
| ™ | Trademark | ™ |
Tip: Always use HTML entities to avoid issues with special characters in HTML code.