Objective

How to load a CSS file into a Joomla PHP page.

Example

URL of the CSS file is contained in the $url variable.

$url = "components/com_mycomponent/assets/css/style.css";

Méthode 1 : JHtml (recommended)

JHtml::stylesheet($url, array(), false);

Méthode 2 : JDocument (older, limited)

$document = JFactory::getDocument();
$document->addStyleSheet($url);


See also:

Source:

 

Keep Me Informed

Keep me informed of the latest extensions releases and offers. One email maximum per month.

Offer Me A Coffee!

If you like my work, offer me a coffee! Nick.