# Ensuring all HTML tags close in text fields

**URL:** <https://www.ruby-forum.com/t/ensuring-all-html-tags-close-in-text-fields/152641>\
**Category:** Rails\
**Created:** [November 5, 2008, 10:38pm UTC](https://www.ruby-forum.com/t/ensuring-all-html-tags-close-in-text-fields/152641 "2008-11-05T22:38:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [November 5, 2008, 10:38pm UTC](https://www.ruby-forum.com/t/ensuring-all-html-tags-close-in-text-fields/152641/1 "2008-11-05T22: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:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [November 5, 2008, 11:38pm UTC](https://www.ruby-forum.com/t/ensuring-all-html-tags-close-in-text-fields/152641/2 "2008-11-05T23:38:17Z")

</div>

On Wed, Nov 05, 2008 at 10:38:05PM +0100, Luke G. wrote:

> 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???

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

–Greg
