title: ITextSharp: Specify HTML Classes or ID CSS
body: <p>I am converting some HTML into a .pdf file using ITextSharp.</p>
  
  <p><strong>Is it possible to set a classes css in ITextSharp or can I only set HTML elements CSS?</strong></p>
  
  <p>For example: If I convert the following HTML</p>
  
  <pre><code>&lt;p class="redBigText"&gt;test&lt;/p&gt;
  </code></pre>
  
  <p>Can I create a ITextSharp StyleSheet object and specify the CSS for the class <strong>redBigText</strong>?</p>
  
  <pre><code>StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
  styles.LoadTagStyle(".redBigText", "font-size", "50px");
  styles.LoadTagStyle(".redBigText", "color", "#ff0000");
  var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(mainContents), styles);
  </code></pre>
  
  <p>Or can I only set CSS elements in ITextSharp?</p>
  
  <pre><code>StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
  styles.LoadTagStyle("P", "font-size", "50px");
  styles.LoadTagStyle("P", "color", "#ff0000");
  var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(mainContents), styles);
  </code></pre>