Make WordPress Core

Opened 6 years ago

Closed 6 months ago

#35299 closed defect (bug) (fixed)

HTML code doesn't always show in page editor

Reported by: JustinBBC Owned by:
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.4
Component: Editor Keywords:
Focuses: Cc:


I have a <style> tag block at the top of a page, but that code does not show in a certain workflow.
1) browse to the dashboard
2) select a page category (Expositions, in my case)
3) select the Edit link for the page that has the <style> tag
--> The Text tab is shown, and all the HTML is shown, no problem
4) select the Visual tab
5) select the Text tab
--> Now the <style> block is missing! Everything below it is shown (a <table> block, in my case).

WordPress 4.4


Attachments (2)

wp_bugshown.PNG (22.1 KB) - added by JustinBBC 6 years ago.
style tag missing
wp_bugnotshown.PNG (24.8 KB) - added by JustinBBC 6 years ago.
style tag shown

Download all attachments as: .zip

Change History (4)

6 years ago

style tag missing

6 years ago

style tag shown

#1 @francbarberini
6 years ago

Hi Justin,
I think this is not a Wordpress or Tinymce editor bug.
<style> tag is actually not a valid element for Tinymce.

I found a solution for your problem here: http://wordpress.stackexchange.com/questions/143628/allowing-style-tag-in-tinymce-editor.

I just tested the code in the answer and it seems to work well.

#2 @sabernhardt
6 months ago

  • Milestone set to 4.6
  • Resolution set to fixed
  • Status changed from new to closed

Support for style and script tags within the post editor was added in WordPress 4.6 with r38039. It works for me now with the Classic Editor, so I think this can be closed as fixed.

The Classic block also retains these tags when switching to code view and back, though the block editor wraps them inside paragraph tags.

Of course, if you can put the CSS somewhere else, such as the theme customizer's Additional CSS, that should be better than adding it within a style tag in the editor.

Note: See TracTickets for help on using tickets.