在引号内插入 HTML

发布于 2024-12-05 09:52:03 字数 488 浏览 2 评论 0原文

我想要在链接的标题属性内添加分页符,但是当我放入分页符时,它在浏览器中显示正确,但在验证时返回 7 个错误。

这是代码。

<a href="images/Bosses/Lord Yarkan Large.jpg" class="hastipz" target="_blank" title="Lord Yarkan, a level 80 Unique from Silkroad Online -- Click for a Larger Image">
<img class="bosspic" src="images/Bosses/Lord Yarkan.jpg" style="float:right; position:relative;" alt="Lord Yarkon; Silkroad Unique"/>
</a>

原因是因为标题属性出现在工具提示中,并且我需要在该工具提示内添加分页符。如何在引号内添加分页符而不返回错误?

I want a page break inside the title attribute of a link, but when I put one in, it appears correct in a browser, but returns 7 errors when I validate it.

This is the code.

<a href="images/Bosses/Lord Yarkan Large.jpg" class="hastipz" target="_blank" title="Lord Yarkan, a level 80 Unique from Silkroad Online -- Click for a Larger Image">
<img class="bosspic" src="images/Bosses/Lord Yarkan.jpg" style="float:right; position:relative;" alt="Lord Yarkon; Silkroad Unique"/>
</a>

The reason is because the title attribute appears in a tooltip, and I need a page break inside that tooltip. How can I add a page break inside the quotes without returning errors?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哑剧 2024-12-12 09:52:03

我发现此论坛帖子

    There are two approaches:

    1) Use the character entity for a carriage return, which is 
 Thus:
    <...title="Exemplary
website">

    (For a full list of character entities, try Googling "HTML Character Codes".)

    2) to do any additional styling to your "tooltips", Google "CSS tooltips"

1)虽然是非标准的。适用于 IE/Chrome,不适用于 Firefox。 新规范似乎推荐 (换行)代替。

I found this forum post:

    There are two approaches:

    1) Use the character entity for a carriage return, which is 
 Thus:
    <...title="Exemplary
website">

    (For a full list of character entities, try Googling "HTML Character Codes".)

    2) to do any additional styling to your "tooltips", Google "CSS tooltips"

1) is Non-standard though. Works on IE/Chrome, not with Firefox. The new spec appears to recommend (newline) instead.

三生一梦 2024-12-12 09:52:03

您需要验证工作吗?

如果没有,如果它按您想要的方式工作,则不必担心错误。

验证不是目标。它是帮助构建更好的网站的工具。这就是目标。 ;-)

如果您必须验证它,您可以尝试使用一些脚本在 dom 准备就绪时为
切换特定关键字/字符集。 虽然这还没有经过测试,我也不确定它不会抛出错误。

编辑

根据要求,用一点 jQuery 来切换单词:

$('a').each(function(){
    var a = $(this).attr('title');
    var b = a.replace('lineBreak','\n');
    $(this).attr('title', b);
});

示例:http://jsfiddle.net/jasongennaro/qRQaq/1/

注意:

  1. 我用过“lineBreak”作为关键字,因为这不太可能匹配。 “br”可能是
  2. 我用 \n 换行符替换的。
  3. 您应该尝试单独使用 \n 换行符...可能无需替换任何内容即可工作。

Do you need to validate for work?

If not, do not worry about the errors if it works as you want it.

Validation is not the goal. It is a tool to help build better Web sites. which is the goal. ;-)

If you must have it validate, you could try to use some script to switch out a specific keyword / set of characters for a <br /> at dom ready. Although this is untested and I am not sure it wouldn't throw errors, too.

EDIT

As requested, a little jQuery to switch out a word:

$('a').each(function(){
    var a = $(this).attr('title');
    var b = a.replace('lineBreak','\n');
    $(this).attr('title', b);
});

Example: http://jsfiddle.net/jasongennaro/qRQaq/1/

Nb:

  1. I used "lineBreak" as the keyword, as this is unlikely to be matched. "br" might be
  2. I replaced it with the \n line break character.
  3. You should try the \n line break character on its own... might work without needing to replace anything.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文