0

I am trying to post block of code like below

$content = '<p>Header</p>'; $content .= '<p><strong>sub-heading</strong></p>';

If I post it in <code> tag, HTML tags are not showing,it just show content only..

How to I post above code in one block with HTML tags.?

It maybe not related to Magento, but I could't ask question in stack overflow, that the reason why I am asking here.

2
  • To post code blocks add 4 spaces at the beginning of the line.
    – sv3n
    Mar 1, 2018 at 9:19
  • beginning of the every line.? Mar 1, 2018 at 9:30

3 Answers 3

5

All lines of your code block have to start with 4 spaces.

Some more information here: How do I format my code blocks?

1
  • Now I got it. Thank you @sv3n Mar 1, 2018 at 9:47
1

add the code in pre tag ie <pre>

1

Sometime takes too long if your having to space each line.

I often use this free handy tool that formats your code ready for stack overflow

1
  • 2
    Pro tip: start without the spaces, then select the code and press Ctrl-K to add indentation Mar 2, 2018 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .