如何停止更改代码? [英] how to stop changing the code?

查看:142
本文介绍了如何停止更改代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天。

我有这个代码:

<div class="align-center">
 <a href="#" class="client">
  <div><img src="./client0.png" alt="" /></div>
  <p class="italic comm"> Test Test Test Test</p>
</a>
</div>

我将此代码粘贴到 textarea code> ckeditor ,但是在按下标签source并返回查看页面后,我得到了更改的代码:

I paste this code in a textarea ckeditor, but after pressing the tab "source" and back to view page I get changed code:

<div class="align-center">
 <div>
 <a class="client" href="#"><img alt="" src="./client0.png" /></a>
 </div>    
 <p class="italic comm"><a class="client" href="#"> Test Test Test Test</a></p>
</div>

请告诉我如何停止更改代码?

Please tell me how to stop changing the code?

推荐答案

这种行为的原因是您的标记无效

The reason for such behavior is that your markup is invalid.

HTML 4.01规范(也是xHTML 2.0)不允许在< div> c $ c>< a> (请参阅此答案)。 CKEditor遵循这些规范,当然,它也发现你的代码无效。不过,CKEditor的解析器试图修复你的HTML,结果是你所说的改变的代码。

HTML 4.01 specification (also xHTML 2.0) doesn't allow block elements like <div> inside <a> (see this answer). CKEditor follows those specs so, of course, it also finds your code invalid. Still, CKEditor's parser tries to fix your HTML and the result is what you call "changed code".

你的代码可能在HTML5中有效。 CKEditor不支持HTML5 DTD ,因为它是复杂和动态的反对HTML 4.01(xHTML 2.0)。

Your code could be valid in HTML5 though. CKEditor doesn't support HTML5 DTD yet because it's complex and dynamic as opposed to HTML 4.01 (xHTML 2.0).

目前,唯一的解决方案是更改您的代码。

At the moment, the only solution is to change your code.

这篇关于如何停止更改代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆