I want to remove css rules which are giving error like here is the example
.banneritem {
border: 1px solid #CED4E0;
border color: #CBCBCB;// is not valid cause it actually refers to border-color missing (-)
margin-bottom: 10px;
}
is there any framework or library which will omit this kind of css rules from file.
I am using sabberworm css parser here my sample code
if ($loadedContents != ""){
preg_match_all('/display: none/is', $loadedContents, $matchvalue);
if (count($matchvalue[0]) > 0) {
$oCssParser = new Sabberworm\CSS\Parser($loadedContents);
$oDoc = $oCssParser -> parse();
foreach ($oDoc->getAllRuleSets() as $oRuleSet) {
if ($oRuleSet instanceof Sabberworm\CSS\RuleSet\AtRule) {
break;
}
$sSelector = $oRuleSet -> getSelectors();
$sSelector = $sSelector[0] -> getSelector();
$aDisplayRule = $oRuleSet -> getRules('display');
if (count($aDisplayRule) > 0) {
$aValues = $aDisplayRule['display'] -> getValues();
if ($aValues[0][0] == "none") {
$displayValue[] = "display:none;";
$displaySelector[] = $sSelector;
}
}
$bDisplayRule = $oRuleSet -> getRules('visibility');
if (count($bDisplayRule) > 0) {
$bValues = $bDisplayRule['visibility'] -> getValues();
if ($bValues[0][0] == "hidden") {
$visibilityValue[] = "visibility:hidden;";
$visibilitySelector[] = $sSelector;
}
}
}
}
}
I am here working all css rules and finds display:none rule in meanwhile due to this faulty rule I am getting fatal error.
Any help will be highly appreciate.
Yes I found the solution,
First of all I put the same code as was in my above question and then I created new dummy css and created new function see below,
For that I use two classes name is
1). csstidy
2). Stylecow
Hope this helps 🙂