Code switch from p to div, why?

Options

Hello,

When I go and add in custom code into the HTML area of a Text content type, it always changes the <p> to <div> (I'm using javascript to grab all the <p> and so when the system switches them over to <div>, it does not work). Then I have to use an embedded widget, which works, but creates some other coding spacing problems in the page footer.

Oh, and my code works in Sublime.

Why does the system switch it?

Thanks,

Tyler

Comments

  • @Tyler Johnson

    Many CMS/WYSIWYG editors have automatic HTML sanitization or reformatting that will rewrite your markup behind the scenes when you save or switch between views, converting to <div> tags. It is hard to say with out being given specifics but you can try instead of the one tag, select both <p> and <div> tags: `document.querySelectorAll('p, div')`

    Maybe a class or attribute to the element with get pass the editor or lean on CSS targeting the widget to fix the spacing issues.

  • @Bryce Howard
    interesting….thanks for responding and I will try that out!

    Cheers.

Categories