Table of Contents

addStyleDeclaration

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Document Class JDocument Method addStyleDeclaration Reference addStyleDeclaration() Never Work in Progress

Adds a stylesheet declaration to the page.

Syntax

void addStyleDeclaration ( $content, $type )

$content string is a string containing the style declarations.
$type string is a string containing the type of style. This parameter is optional and if omitted defaults to ‘text/css’.

Examples

This example adds a style declaration to the page.

Example

global $mainframe;

$style = "body {"
        . "\n margin: 0px 0px 0px 0px;"
        . "\n height: 100%;"
        . "\n font-size: 76%;"
        . "\n}";

$document = &JFactory::getDocument();
$document->addStyleDeclaration( $style );

Might add the following code to the head block of the current page:

Result

<style type="text/css">
<!--
    body {
        margin: 0px 0px 0px 0px;
        height: 100%;
        font-size: 76%;
    }
-->
</style>