public function style(DOMElement &$element, $name, $val = '')
    {
        // Get all styles from the element
        $elementStyle = $this->attr($element, 'style');
        $elementStyle = trim($elementStyle, '; ');

        $styleArray = [];
        if (!empty($elementStyle)) {
            $styleArray = explode(';', $elementStyle);
        }
        $styles = [];
        foreach ($styleArray as $stylePair) {
            $pair = explode(':', $stylePair);
            $styles[trim($pair[0])] = trim($pair[1]);
        }

        // If value is null or false, remove attribute
        if (is_null($val) || (is_bool($val) && $val === false)) {
            unset($styles[$name]);
        } else if (empty($val)) {
            if (isset($styles[$name])) {
                return $styles[$name];
            }

            return null;
        } else {
            $styles[$name] = $val;
        }

        // Pack all styles into one value
        $styleArray = [];
        foreach ($styles as $name => $value) {
            $pieces = [$name, $value];
            $styleArray[] = implode(': ', $pieces);
        }
        $elementStyle = implode('; ', $styleArray);

        // Set style attribute
        $this->attr($element, 'style', (empty($elementStyle) ? null : $elementStyle));

        // Return the HTML element
        return $element;
    }