private static bool IsCssTypeAttribute(HtmlTag tag, HtmlAttribute attribute)
{
string tagNameInLowercase = tag.NameInLowercase;
string attributeNameInLowercase = attribute.NameInLowercase;
string attributeValue = attribute.Value;
IList<HtmlAttribute> attributes = tag.Attributes;
bool isCssTypeAttribute = false;
if (tagNameInLowercase == "link" || tagNameInLowercase == "style")
{
string processedAttributeValue = attributeValue.Trim();
if (attributeNameInLowercase == "type" && processedAttributeValue.IgnoreCaseEquals(CSS_CONTENT_TYPE))
{
if (tagNameInLowercase == "link")
{
isCssTypeAttribute = attributes.Any(a => a.NameInLowercase == "rel"
&& a.Value.Trim().IgnoreCaseEquals("stylesheet"));
}
else if (tagNameInLowercase == "style")
{
isCssTypeAttribute = true;
}
}
}
return isCssTypeAttribute;
}