简体   繁体   English

嵌入式图像如何在HTML中工作?

[英]How embedded image works in HTML?

I was reading a blog and I came across a simple snippet that rendered image without img tag or CSS. 我正在阅读一个博客,偶然发现了一个简单的片段,该片段呈现了没有img标签或CSS的图像。 I would like to know how this works. 我想知道这是如何工作的。

Snippet: 片段:

<span id="pie">🥧</span>

Copy and paste it in HTML file and the image gets rendered. 将其复制并粘贴到HTML文件中,即可渲染图像。 How does this work? 这是如何运作的? and what type of image can we embed in here? 我们可以在这里嵌入哪种类型的图像?

The reason that you can do that is because the "image" that is used is actually an emoji. 之所以可以这样做,是因为使用的“图像”实际上是表情符号。 Emojis are considered to be characters, like letters in the alphabet, but it has colors. 表情符号被认为是字符,就像字母表中的字母一样,但是它具有颜色。 That's why it can be rendered without an <img> tag. 这就是为什么可以在没有<img>标签的情况下渲染它的原因。

It's not an image, but an emoji inserted using the decimal (dec) or hexadecimal (hex) code (just like you render spaces using &nbsp; ). 它不是图像,而是使用十进制(dec)或十六进制(hex)代码插入的表情符号(就像使用&nbsp;渲染空格一样)。 Check examples here 在此处查看示例

Here's another example snippet 这是另一个示例片段

<span style='font-size:100px;'>&#129312;</span>

and it renders : 🤠 它呈现:🤠

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM