Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8919269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:58:36+00:00 2026-06-15T05:58:36+00:00

I want to remove css rules which are giving error like here is the

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:58:38+00:00Added an answer on June 15, 2026 at 5:58 am

    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

      require "../stylecow/autoload.php";
    
      //for css rules omition
    
      require('../csstidy/class.csstidy.php');
    
    function makeDummyCssFile($html)
    {
            $cssTidy = new csstidy();
            $newCss ="";
          foreach ($html->find('link') as $e) {
            $cssHrefs = $e -> href;
            preg_match_all('~favicon~is', $cssHrefs, $feviMatch);
            if (count($feviMatch[0]) == 0) {
                preg_match_all('~(\bhttp|https\b)~is', $cssHrefs , $isThirdPartyCss);
                if(count($isThirdPartyCss[0]) >  0)
                {
                    $loadedHrefs = $cssHrefs;
                }
                else
                {
                    preg_match_all('~' . SITE_NAME . '~is', $cssHrefs, $match);
                    if (count($match[0]) == 0) {
                        $loadedHrefs = SITE_NAME . $cssHrefs;
                    } else {
                        $loadedHrefs = $cssHrefs;
                    }
                }
    
                    $loadedContents = file_get_contents($loadedHrefs);
                    $css = Stylecow\Parser::parseFile($loadedContents);
                    $newCss.= $css;
            }
        }
    
    
    
                 $result = $cssTidy->parse($newCss);
    
                 $newCss = $cssTidy->print->plain();
                 if($result)
                 {
    
                     foreach($cssTidy->log as $line => $array)
                            {
                               // echo "<pre>";print_r($array);
                                $array_size = count($array);
                                for($i = 0; $i < $array_size; ++$i)
                                {
                                    if($array[$i]['t'] == "error")
                                    {
    
                                       $newCss =   preg_replace("~(".$array[$i]['m']['selector']."[^\}]*\})~is", "", $newCss);#qtip-overlay div[^\}]*\}
                                    }
    
    
                                }
                            }
    
                 }
            $cssName = explode("http://", SITE_NAME);
            $cssFileName = str_replace(".", "-", str_replace("/","",$cssName[1])) . "-" . date('Y-m-d') . ".css";
            $str = "";
            $myFile = DUMYPATH . $cssFileName;
                        if ($myFile != "") {
    
                            $fh = fopen($myFile, 'w+') or die("can't open file");
                            $stringData = $newCss;
                            fwrite($fh, $stringData);
                            fclose($fh);
                        }
            return $cssFileName;
    }
    

    Hope this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'd like to remove some specific css rules (i.e. width and height) out of
I have the following syntax in which I want to remove all css classes
want to remove all css rules from inline css but not to remove display
I want to remove a css class before adding a new class to an
i want to remove the link from my header using CSS so that only
I want to remove the last right border in a row of links? #mainMenu
I want to remove the string code=hads1328fas& on my URL, so that BEFORE http://example.com/main/index.php?code=hads1328fas&store=food#home
I want to remove duplicate lines from a file, without sorting the file. Example
I want to remove all lines in a CSS file that contain the word
i want to remove the vertical line。which is in the red circularity. ! but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.