Software Development

Display a Red Asterisk before a Label in JSF for Required Fields



For the most part, this is a generic CSS/HTML tip but this article demonstrates how to display a red asterisk for labels in JSF for required fileds.

Software Environment

  • Windows 7 Professional SP1
  • Eclipse – Kepler Release
  • Java 1.7 (1.7.0_67 – Windows x86)
  • JSF 2.2
    • Downloaded, and referenced as part of a Dynamic Web Project in Eclipse
  • Primefaces 4.0
    • Downloaded from
    • Place it in the project in WebContent\WEB-INF\lib and reference it

The Red Asterisk

To create a red asterisk that displays before any labels in JSF for required fields, simply create an inline CSS.

You may place this in your .xhtml file just like you would in a normal html file. Alternatively, you can put this in an external CSS file and simply reference it from you page.

Using Your Inline CSS

Just below your inline CSS, use styleClass to reference the style class.


Got comments, or suggestions? Please visit our Facebook page!

You Might Also Like


  1. 1
  2. 2

Comments are closed.