Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Markdown Images

Markdown Images

Images make documents more vivid and easier to understand.

Markdown's image syntax is concise and flexible.

The Markdown image syntax format is as follows:

![替代文字](图片路径)

![替代文字](图片路径 "图片标题")

Relative path example:

![项目截图](./images/screenshot.png)

![用户界面](../assets/ui-demo.jpg "用户界面演示")

![图标](images/icon.svg "应用图标")

Absolute path example:

![本地图片](/Users/username/Documents/image.png)

![系统截图](C:\Users\username\Pictures\screenshot.png)

Path usage suggestions:

Reference web images directly:

![RUNOOB 图标](https://static.jyshare.com/images/runoob-logo.png)



![RUNOOB 图标](https://static.jyshare.com/images/runoob-logo.png "RUNOOB")

The display result is as follows:

Of course, you can also use variables for the image URL just like with web addresses:

这个链接用 1 作为网址变量 [RUNOOB][1].

然后在文档的结尾为变量赋值(网址)



[1]: https://static.jyshare.com/images/runoob-logo.png

The display result is as follows:

Markdown still cannot specify image height and width; if you need to, you can use plain tag.



The display result is as follows:

Use a CDN service:

![示例图片](https://cdn.jsdelivr.net/gh/user/repo/image.png)

![Unsplash 图片](https://images.unsplash.com/photo-1506905925346-21bda4d32df4)

Notes on web images:

The importance of image alt text

Alt text provides alternative information when an image cannot be displayed, and is also important for accessibility and SEO:

Good alt text examples:

![苹果公司总部大楼外观,现代玻璃幕墙建筑](./images/apple-headquarters.jpg)

![网站流量统计图表,显示过去六个月的访问量呈上升趋势](./charts/traffic-stats.png)

![用户登录界面,包含用户名和密码输入框](./screenshots/login-page.png)

Alt text to avoid:

![图片](image.jpg)  // 太简单,没有描述性

![](image.jpg)      // 完全没有 alt 文本

![点击这里](image.jpg)  // 不描述图片内容

Alt text best practices:


Image size control (HTML method)

Standard Markdown does not support directly controlling image size, but you can use HTML tags.

Use the HTML img tag:

Caption text

Caption text

Caption text

Responsive images:

Caption text

Image alignment:



Centered image
Left-aligned image Right-aligned image

Advanced usage of links and images

Image-link combinations

Make the image a clickable element of a link.

Basic syntax:

[![图片alt文本](图片URL)](链接URL)

Practical example:

[![GitHub项目截图](./images/project-screenshot.png)](https://github.com/username/project)

[![访问官网](https://example.com/logo.png)](https://example.com "点击访问官网")

Common use cases:



[![Build Status](https://travis-ci.org/user/repo.svg?branch=master)](https://travis-ci.org/user/repo)

[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)





[![App Store](./images/app-store-badge.png)](https://apps.apple.com/app/your-app)

[![Google Play](./images/google-play-badge.png)](https://play.google.com/store/apps/details?id=com.yourapp)

Relative and Absolute Paths

Advantages of relative paths:



project/

├── README.md

├── docs/

│   ├── guide.md

│   └── images/

│       └── screenshot.png

└── assets/

    └── logo.png





![Logo](./assets/logo.png)





![Screenshot](./images/screenshot.png)

![Logo](../assets/logo.png)

Path planning suggestions:

Image centering and alignment

Method 1: HTML + CSS

Centered image

** Method 2: Use HTML alignment attributes **

Centered image

** Method 3: Create an image gallery **

Image 1 Image 2 Image 3

Useful image display templates:

## 产品展示



### Main Features

Feature 1
智能识别
AI驱动的图像识别技术
Feature 2
快速处理
毫秒级响应速度
### 界面预览 | 移动端 | 桌面端 | |:---:|:---:| | ![移动界面](./images/mobile.png) | ![桌面界面](./images/desktop.png) | | 响应式设计,完美适配 | 大屏体验,功能齐全 |

Performance optimization suggestions:

Troubleshooting links and images

Common problems and solutions:

Debugging tips:



测试链接:[点击测试](https://httpbin.org/get)





![测试图片](./images/test.png)



By mastering the various uses of links and images, you can create Markdown documents with rich content and clear navigation. These skills are very important for writing technical documentation, project descriptions, and online content.