-3

Suppose i need to write a website that gives a tutorial on html or codes.

<html><h1>Hello World</h1></html>

Then how can i write this code within it. i tried to use <code></code> and even <pre></pre> to enclose the html code so that it will not be intrepreted but it got intrepreted by the browser. So how can i display the html code within the html file in browser like a code sample..

Barthdry
  • 7
  • 4

1 Answers1

-2

You have to write htlm reserved code with html entities

https://www.w3schools.com/HTML/html_entities.asp

The 2 main ones

< -> &lt; 

> -> &gt;
Dri372
  • 1,275
  • 3
  • 13
  • Does the one who downvite explain why and give a better answer ... – Dri372 Jun 17 '21 at 09:01
  • I'm guessing it's because this question is a common duplicate. [We mark questions as duplicate](https://stackoverflow.com/help/duplicates) so all the content can be found in one place. Answering them doesn't help. – Ivar Jun 17 '21 at 09:02
  • @lvar maybe, but not the right way to help ... – Dri372 Jun 17 '21 at 09:05
  • I'm not sure what you are referring to with "not the right way to help"? – Ivar Jun 17 '21 at 09:09
  • @lvar An answer for the OP and explanation for me? – Dri372 Jun 17 '21 at 12:28
  • OP got a more than excellent answer in the marked duplicate. Another answer doesn't add any value what so ever. And an explanation would be nice, but many here have experienced explaining their votes to backfire (by users revenge downvoting their posts or even harassing them on social media) and so they stopped with it. I can't blame them. – Ivar Jun 17 '21 at 12:34
  • @lavr OP got a more than excellent answer in the marked duplicate.... OK but after the 2 previous answers. ... For the last point, it's unfortunatly in 'human nature' but with a mandatory comment every one could see such action ... – Dri372 Jun 17 '21 at 12:43
  • One thing to keep in mind is that Stack Overflow is not meant as a help desk. We're a Q&A repository that aims to be helpful to _future visitors_ who are facing the same issue (who can find these answers through search engines). Helping the OP is just a nice side-effect. If every question gets repeated and answered hundreds of times, all the good content will be shattered and will be less helpful to those future visitors. The curators of this site care _a lot_ about the quality, causing answers like these to be downvoted. – Ivar Jun 17 '21 at 12:55
  • OP having to scroll down a bit in a duplicate is really not an issue. (Though in this case, also the very first answer answers the question, as long as you keep the sorting of the answers on "votes".) And the mandatory comment on votes has been brought up many times on [meta]. [Never ends well](https://meta.stackoverflow.com/questions/357436/why-isnt-providing-feedback-mandatory-on-downvotes-and-why-are-ideas-suggestin). – Ivar Jun 17 '21 at 12:56
  • s not meant as a help desk. :-) My answer gives a link , not a so link ... maybe OP and me and not enough fluent in english, or ... to find the right answer in so ... – Dri372 Jun 17 '21 at 13:08
  • @lavr Thanks for your last answer I'll read it ... – Dri372 Jun 17 '21 at 13:08
  • @lavr the link is clear , it should exist a welcome process explaining briefly explaining the rules of the 'big city' with links to deeper explanations. – Dri372 Jun 18 '21 at 12:25