link_tag([$href = ''[, $rel = 'stylesheet'[, $type = 'text/css'[, $title = ''[, $media = ''[, $index_page = FALSE]]]]]])
| Parameters: |
|
|---|---|
| Returns: |
HTML link tag |
| Return type: |
string |
Lets you create HTML <link /> tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page.
index_page is a boolean value that specifies if the href should have the page specified by $config['index_page'] added to the address it creates.
Example:
echo link_tag('css/mystyles.css');
// gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
Further examples:
echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');
// <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');
// <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
Additionally, an associative array can be passed to the link() function for complete control over all attributes and values:
$link = array(
'href' => 'css/printer.css',
'rel' => 'stylesheet',
'type' => 'text/css',
'media' => 'print'
);
echo link_tag($link);
// <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
Please login to continue.