When visiting any website, you’ve likely noticed that images make the pages more engaging and visually appealing. If content were limited to text alone, it would look dull and monotonous. Visual elements help users better understand and remember information while also making the interface more user-friendly.
Markdown is a simple and user-friendly markup language used to create text with minimal effort. It’s widely used for writing documentation, articles, and blog posts. Markdown also allows you to add images to your text, which play a crucial role in visualizing content, making it more comprehensible and memorable.
There are two primary methods for adding images in Markdown: using local images and external links.
It’s essential to correctly specify the file path to insert images stored locally. It’s recommended to store images either in the same directory as the Markdown file or at the same hierarchical level.
If the image is in the same directory as the .md file, simply provide the file name:
![Computer](computer.png)
If the image is in a subdirectory (e.g., /img
) within the project folder, specify the path as follows:
![Computer](img/computer.png)
The text in square brackets ([Computer]
) is the alternative text (alt-text). This text appears if the image fails to load and helps screen readers describe the image for visually impaired users.
The image path is enclosed in parentheses. Ensure the path is correct to avoid issues with image display after uploading to a server.
To insert an image hosted on the internet, use its URL:
![Image Description](https://site/photo.png)
Advantages of using external images:
Saves repository space: You don’t need to store large image files locally.
Easy content management: It’s convenient when images are updated frequently.
Disadvantages:
Dependency on the external source: If the image is removed or the URL changes, the image will no longer display.
In standard Markdown, there is no built-in support for controlling image sizes (except for platforms like GitHub and others where this feature has been manually added), but you can use HTML for this purpose:
<img src="/img/computer.png" alt="Computer" width="500" height="300">
Enhanced formatting helps draw attention and makes the content more accessible and easier to read.
Captions for images are important as they provide additional information to the reader.
![Computer](/img/computer.png "Text below the image")
To create a clickable image that links to another resource, wrap the image syntax in square brackets with a link:
[![Computer](/img/computer.png)](https://site)
Alt text should describe the content of the image and be clear for all users.
Bad alt text:
![Computer](/images/picture.jpg)
Good alt text:
![The first computer ever built](/img/computer.png)
Accessibility: Users with visual impairments use screen reader programs that read the alt text aloud.
SEO: Search engines index alt text, helping your content to be found through search queries.
Try to use images with the smallest file size possible to speed up page loading.
Optimize images before uploading to avoid large file sizes and long loading times.
Ensure that the alt text is unique and accurate.
The file name should be relevant and include keywords. For example, instead of img123.png, use computer-setup.png.
There are various methods to insert images, each with its own pros and cons. Below is a comparison table.
Method |
Advantages |
Disadvantages |
Markdown syntax |
Simple and fast insertion |
Less flexibility in customization |
HTML markup |
Full control over style and size |
More complex syntax |
Combination of Markdown and HTML |
Combines simplicity and flexibility |
Requires basic HTML knowledge |
Now you know how to insert images in Markdown, control their size, add captions, and make content more accessible using alt text. Using images makes the text more visual and helps readers better comprehend the information.
Check out our reliable and high-performance WordPress hosting solutions for your WordPress websites.