How do I print the field ID of a category field in place of its title? How do I print the field ID of a category field in place of its title?

{% for entry in craft.entries.section('posts').relatedTo(category) %}
    some html...
    {% for category in entry.market.level(2).find() %}
        {{ category.title }}
    {% endfor %}
{% endfor %}


I want to print the field ID of category.title instead.  

Reason = I am using the printed output as a class to filter against.  Some of the category titles contain more than one word and I do not want to add a hyphen to each instance.   So, using the field ID in place of category.title  would solve this problem.
Would using {{ category.id }} work?