We are developing a templates application that allows users to input HTML/CSS code within a textarea. Most of our users are well-versed in html and css, hence we have not integrated markdown into the system yet. An important feature we want to include is the ability to preview the html content from the textarea before submission. I have brainstormed several methods to achieve this functionality, but I am uncertain which approach would be optimal and most sustainable.
- Display the html content inside a div on the same page - there is concern that the existing CSS styles may conflict with those inputted by the user in the textarea. Additionally, if the user includes a body tag in the textarea, it could result in nested body tags causing malformed html.
- Show the html content in a separate window - this method presents challenges as I do not have full control over it (e.g. issues with pop-up blockers).
- Present the html content in a separate tab - this may confuse users leading to accidental closure of the entire browser mistaking it for a new window.
- Embed the html content in an iframe - while feasible, this would require the creation of an additional .html file solely for preview purposes.
- Display the html content in a modal - though achievable, there are uncertainties around whether modal bodies can accommodate top-level tags like title or body.
I am seeking assistance. Which of these proposed solutions would be most effective? Or is there an alternative option that may serve better?