# Ensuring all HTML tags close in text fields

**URL:** <https://discuss.rubyonrails.org/t/ensuring-all-html-tags-close-in-text-fields/36083>\
**Category:** rubyonrails-talk\
**Created:** [November 5, 2008, 9:38pm UTC](https://discuss.rubyonrails.org/t/ensuring-all-html-tags-close-in-text-fields/36083 "2008-11-05T21:38:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [November 5, 2008, 9:38pm UTC](https://discuss.rubyonrails.org/t/ensuring-all-html-tags-close-in-text-fields/36083/1 "2008-11-05T21:38:05Z")

</div>

Does anyone know of a way/method/plugin for ensuring HTML tags all close and/or close them automatically when the data is pulled or pushed into the database???

---

<div class="post-metadata">

**Author:** ![Gregory\_Seidman1](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@Gregory\_Seidman1](https://discuss.rubyonrails.org/u/Gregory_Seidman1)\
**Post date:** [November 5, 2008, 10:35pm UTC](https://discuss.rubyonrails.org/t/ensuring-all-html-tags-close-in-text-fields/36083/2 "2008-11-05T22:35:57Z")

</div>

Look into Hpricot. Doing Hpricot(htmltext).to\_html will give you well-formed (i.e. all tags close) HTML.

--Greg
