HTML string formatting inside string format

940 Views Asked by At

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>”"
2

There are 2 best solutions below

0
AudioBubble On

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; ?>">
0
Michael On

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>"