How do you show <img> tags on screen, as code?

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do you show <img> tags on screen, as code?

Post by simonmlewis »

I want to provide the IMG code to someone on a webpage, without it rendering as an image.

ie.

<img src='.....' >/ And it show on screen as code.

How do you do it?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: How do you show <img> tags on screen, as code?

Post by Christopher »

Code: Select all

$html_with_img = '<img src="....." >';
echo htmlspecialchars($html_with_img);
(#10850)
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you show <img> tags on screen, as code?

Post by simonmlewis »

For some reason, when I narrow the screen to mobile format, the text in the box goes off the screen, as it's not properly wrapping.
Is there a way to force it to wrap?

It's cause a horiz-slider on the browser.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: How do you show <img> tags on screen, as code?

Post by Christopher »

Put <br> in the places you want it to wrap?
(#10850)
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you show <img> tags on screen, as code?

Post by simonmlewis »

Sorry?
The resulting code being rendered is random.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: How do you show <img> tags on screen, as code?

Post by Christopher »

It is not wrapping because there are long stretches of characters without a space. You can manually wrap it at a specific length, or use Javascript to wrap it based on the width of the window.
(#10850)
Post Reply