PHP code example of gemorroj / cssvalidator
1. Go to this page and download the library: Download gemorroj/cssvalidator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gemorroj / cssvalidator example snippets
use CSSValidator\CSSValidator;
use CSSValidator\Options\Options;
use CSSValidator\Options\ProfileType;
use CSSValidator\Options\UserMediumType;
use CSSValidator\Options\WarningType;
$options = (new Options())
->setProfile(ProfileType::Css21) // or a string, e.g. 'css21'
->setWarning(WarningType::All)
->setUserMedium(UserMediumType::Screen)
->setLang('en');
$validator = new CSSValidator($options);
$result = $validator->validateFragment('#css-code { background: green; }');
$result = $validator->validateFile('/path/to/file.css');
$result = $validator->validateUri('http://example.com/style.css');
$result = $validator->validateUri('http://example.com'); // extract and validate all CSS files on that page
echo $result->getCssLevel();
var_dump($result->isValid());
print_r($result->getErrors());
print_r($result->getWarnings());