Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
james_botten
New Member

Hiding HTML code using the "<!---" tag

Jump to solution

I'm hoping to use the "<!---" and "--->" tags to hide text in a webpage template so that it can be reused for multiple purposes.  When editing a page in Canvas using the HTML code view, the code after the "<!---" tag is grayed out as expected and when viewing the saved page the relevant text is hidden.

However it seems this hidden text is actually deleted, as when the page is re-opened for editing, all the relevant HTML code between the "<!---"/"--->" tags is simply not there. 

I know I can store multiple pages as templates, but I'd prefer to have the flexibility of working with fewer templates that have hidden code snippets to reactivate as needed.

Is this a glitch or is there some specific reason for the "<!---" tag working this way?

Labels (1)
0 Kudos
1 Solution

Accepted Solutions
chofer
Community Coach
Community Coach

Good evening, @james_botten ...

I don't think it's a glitch.  There are only certain HTML elements that are allowed in the Canvas RCE (Rich Content Editor).  You can read more about this by checking out the following PDF file in this Guide: Canvas HTML Editor Allowlist PDF - Instructure Community (canvaslms.com).

Hope this helps a bit.

View solution in original post

4 Replies
chofer
Community Coach
Community Coach

Good evening, @james_botten ...

I don't think it's a glitch.  There are only certain HTML elements that are allowed in the Canvas RCE (Rich Content Editor).  You can read more about this by checking out the following PDF file in this Guide: Canvas HTML Editor Allowlist PDF - Instructure Community (canvaslms.com).

Hope this helps a bit.

Thanks @chofer, I didn't realise some tags were not allowed.

Appreciate the heads up.

Cheers
Jamie

WatsonWork
New Member

Another option is to use CSS functionality.

 

You can also achieve the "hiding" by using CSS display:none. This isn't removed in Canvas and allows HTML blocks (span, img, a, div...) to be hidden from view - but still accessible if you want to reactivate at a latter time.

The content is still viewable if a person uses View Source (or the like) as the content is still in the HTML.

This is commonly used in JS to make things appear but doesn't have to be JS controlled. I wanted an IMG to not be viewable for a short period of time, but want it to reappear after week 2 or 3. You can thing wither take out the style or set it to inline/block etc.

It used to work - a year or more ago.  With one of the updates (maybe the new Rich Text Editor?) it stopped being possible.