html - Contenteditable paragraph tag on enter -


i wondering if there acceptable way force major browsers insert paragraph tag instead of default tag insert on pressing enter key when contenteditable true.

as far know ie inserts p automatically. google chrome inserts div tag , firefox inserts br (wtf?!).

thanks in advance!

you can use document.execcommand('formatblock', false, 'p'); in event keypress or keydown, etc. use paragraphs after enter press. example:

element.addeventlistener('keypress', function(ev){     if(ev.keycode == '13')         document.execcommand('formatblock', false, 'p'); }, false); 

Comments

Popular posts from this blog

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -

Python __call__ special method practical example -