title: How to inject CSS in WebBrowser Control
body: <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
          webBrowser1.Navigate("https://www.aparat.com/aleffamily/live2");
          webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
  
      }
  
      private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
      {
  
          HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
          HtmlElement styleEl = webBrowser1.Document.CreateElement("style");
          IHTMLStyleElement element = (IHTMLStyleElement)styleEl.DomElement;
          IHTMLStyleSheetElement styleSheet = element.styleSheet;
          styleSheet.cssText = @"body {background-color:transparent !important; margin: 0px auto; overflow: hidden; }.live__content{display:none;}.chat__footer{display:none;}.chat__header{display:none}#header{display:none}.in-chat-avatar{display:none}.message__username{font-style:italic;font-weight: 800!important;color:ff8f0f !important}.message__text{font-style:italic;font-weight: 400!important;color:ff8f0f !important}.chat__content{ background-color:transparent  !important}.chat{ background-color:transparent  !important}";
          head.AppendChild(styleEl);
  
      }
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This code has not worked for me and I am getting this error</p>
  
  <blockquote>
    <p>Error  1   The type or namespace name 'IHTMLStyleSheetElement' could
    not be found (are you missing a using directive or an assembly
    reference?)    C:\Users\aleffamily\documents\visual studio
    2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
    30  13  WindowsFormsApplication1</p>
  </blockquote>