-1

I want to put a <p> tag into my headline, I have tried to do it this way but the <p> tags are not shown in the header:

<h1> <p>I want to see the p tags!</p> </h1>

How can I force the <p> tags into the header string?

Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
Jakob
  • 5
  • 4

4 Answers4

2

Nothing.

<h1> elements may not have <p> element descendants.

See the specification which says that the h* elements Content model is "Phrasing content", which does not include p elements.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • But what if i want to write at header containing the text "

    whatever

    "?
    – Jakob Nov 23 '17 at 13:28
  • Then the `

    ` element is irrelevant to the problem and you are asking a duplicate of https://stackoverflow.com/questions/2820453/display-html-code-in-html

    – Quentin Nov 23 '17 at 13:29
2

Something like this?

<h1> &lt;p&gt;I can see the p tags!&lt;/p&gt; </h1>
Marcel
  • 1,443
  • 2
  • 14
  • 24
0

<h1><p> is not meaningful markup. It cannot be header and a paragraph. What are you trying to do? If you simply want the header to be styled in the same way as the paragraph then add some styles. An example inline would be:

p, h1 {
  font-size: 0.7em;
  font-weight: normal;
}

this will make both <h1> and <p> the same.

Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
0

replace < by &lt; and > by &gt;

DMC19
  • 825
  • 2
  • 14
  • 33