鱼C论坛

 找回密码
 立即注册
查看: 3318|回复: 4

[已解决]萌新求助, html5的<meta>标签

[复制链接]
发表于 2018-4-21 11:47:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
<meta>标签中 charset和http-equiv="content-type"在web速查中不是一样的效果么,为什么,下面两段代码,其中代码1的中文是乱码,代码2正常显示,用win10自带的edge浏览器打开,用chrome两种无差别,


代码1:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>懒得写(反正你们也看不到)</title>
  5.         <meta http-equiv="content-type" content="text/html charset=UTF-8">
  6. </head>
  7. <body>
  8.     <h1>“自适应”演示</h1>
  9.     <p>请分别在PC和手机上打开该页面!</p>
  10.     <img id="target" src="../img/FishC.png" alt="鱼C-Logo" width="256px" height="256px">
  11.     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  12.     proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  13. </body>
  14. </html>
复制代码


edge显示: @FNCZAJQYD9T1K(U2R)`~ZI.png




                               
登录/注册后可看大图




代码2:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>懒得写(反正你们也看不到)</title>
  5.         <meta charset="utf-8">
  6. </head>
  7. <body>
  8.     <h1>“自适应”演示</h1>
  9.     <p>请分别在PC和手机上打开该页面!</p>
  10.     <img id="target" src="../img/FishC.png" alt="鱼C-Logo" width="256px" height="256px">
  11.     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  12.     proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  13. </body>
  14. </html>
复制代码
最佳答案
2018-4-22 11:14:42
Congroo 发表于 2018-4-21 15:50
也就是说不能用代替,这两种有么子区别么~~~


只要你在代码2中,有声明meta元素且有charset="utf-8"。

那么用现代浏览器(Chrome,firefox,safari...)就不会出现中文乱码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-4-21 15:18:35 | 显示全部楼层
chrome 内置utf-8

用中文, <meta charset="utf-8">,必须要写~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-4-21 15:50:46 | 显示全部楼层
不二如是 发表于 2018-4-21 15:18
chrome 内置utf-8

用中文, ,必须要写~

也就是说不能用
  1. <meta http-equiv="content-type" content="text/html charset=UTF-8">
复制代码
代替,这两种有么子区别么~~~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-4-22 11:14:42 | 显示全部楼层    本楼为最佳答案   
Congroo 发表于 2018-4-21 15:50
也就是说不能用代替,这两种有么子区别么~~~


只要你在代码2中,有声明meta元素且有charset="utf-8"。

那么用现代浏览器(Chrome,firefox,safari...)就不会出现中文乱码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-4-22 11:54:57 | 显示全部楼层
不二如是 发表于 2018-4-22 11:14
只要你在代码2中,有声明meta元素且有charset="utf-8"。

那么用现代浏览器(Chrome,firefox,safar ...

谢谢大神
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-5 04:06

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表