public static bool HasCssClass(this AttributeDictionary attributes, string className) { var value = attributes.FirstOrDefault(x => x.Key == "class").Value; if (string.IsNullOrWhiteSpace(value)) { return(false); } var classNames = value.Split(" "); var any = classNames.Any(x => x == className); return(any); }