Please can anyone show me a proper way to program the Tags field so that it looks like the stackoverflow one.
As in:

I suspect it is done in HTML/CSS and Javascript. Any suggestions or ideas are greatly appreciated. I would be grateful as well, if you can write some illustration code or direct me to some sort of tutorial.
If you can use jQuery here are some good options:
From the jQuery folks themselves:
http://archive.plugins.jquery.com/project/jQueryTagEditor
This one is easiest to see in action right from the web page link:
http://jcesar.artelogico.com/jquery-tagselector/
Others:
https://github.com/xoxco/jQuery-Tags-Input
https://github.com/webworka/Tagedit
https://github.com/aehlke/tag-it
http://ioncache.github.com/Tag-Handler/