How does StackOverflow create its tag system. How can it format the html in a text area?
I just don't know where to begin. If someone could guide me, then I can know what direction to take so I can write some code that someone can check.
Like this:
EDIT: Basically, when I press space, how do i add a new element/div to the inside of the div?
It doesn't. If you look at the DOM, you see initially just an input box. Once you add a tag, it inserts a
<span>
tag before the input box with that tag and it's delete icon. The input box is now to the right of this<span>
tag. When you click on a tag to edit it, it puts a textbox in its place so you can edit it. All this is done with Javascript and there are some JQuery plugins to help you do this. Here's one from a quick Google search: http://xoxco.com/projects/code/tagsinput/As far as styling goes, the
<span>
elements can have whatever CSS you want on them.What I would do is :
When you write inside the input and let's say you select HTML, it create a span in the left DIV and reduce the width of the right div to match the remaining size. Of corse, inside your span there's the text HTML with the delete sign.
You could do it easilly using jQuery.
Example :
And you write some jQuery / JS
What about Bootstrap solution?
You can try this :
HTML Code:
For CSS, call these two files:
For Javascript, call these two files:
The code will generate the result below:
Check it out.