简体   繁体   中英

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. 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. 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? 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="<h1 class=’sourcesans’ style=’font-size:30px;color:#9a2425;font-weight:600;padding-bottom:30px’>Sterling Assets Management & Trustees Limited</h1>"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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