Using drupal_add_css to dynamically add inline CSS based on term reference
If using render you should attach the css to that render array.

$term = taxonomy_term_load($node-&gt;field_example_category['und'][0]['tid']);
$category_color = field_view_field('taxonomy_term',$term,'field_example_category_color');
$name = $term-&gt;name;
$category_color['#attached']['css'][] = array(
  'data' =&gt; ".bg-unit-color {background-color: $name;}", 
  'type' =&gt; 'inline',
);