简体   繁体   English

字符串格式内的HTML字符串格式

[英]HTML string formatting inside string format

I'm using cycle 2 advanced custom template http://jquery.malsup.com/cycle2/demo/caption.php but I want to format the content of the alt attribute. 我正在使用第2周期高级自定义模板http://jquery.malsup.com/cycle2/demo/caption.php,但我想格式化alt属性的内容。 I'm trying to enter the actual HTML as a string as it's alt attribute but my formatting doesn't work cause the text comes out as black instead of a shade of red. 我正在尝试将实际的HTML作为字符串的alt属性输入,但是我的格式不起作用,因为文本显示为黑色而不是红色。 Here is my alt string code. 这是我的替代字符串代码。

alt="“<h1 class=’sourcesans’ style=’font-size:30px;color: #9a2425;font-weight: 600;padding-bottom: 30px’>Sterling Assets Management & Trustees Limited</h1>”"

Have you tried saving the alt HTML you want in a php variable and then echoing it out on the HTML level? 您是否尝试过将所需的替代HTML保存在php变量中,然后在HTML级别上将其回显? If not please try this: 如果没有,请尝试以下操作:

Here's a guide and should help you on your way... Excerpt : 这是一个指南 ,应为您提供帮助...摘录:

<img alt="<?php echo "Title" . "Lorem Ipsum dolor" . "<a href='http://www.google.com'>View Website</a>"; ?> " src="<?php echo $img; ?>">

You are using some curly quotes (' and ', “ and ”) instead of the standard straight quotes (' and "). Curly quotes won't get processed correctly, you need to use straight ones. 您使用的是一些弯引号(“和”,“和”),而不是标准的直引号(“和”)。如果不能正确处理弯引号,则需要使用直引号。

If you write your alt tag like this it will work. 如果您这样编写alt标签,它将起作用。

alt="<h1 class=’sourcesans’ style=’font-size:30px;color:#9a2425;font-weight:600;padding-bottom:30px’>Sterling Assets Management & Trustees Limited</h1>"

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

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