CodeIgniter and The HTML Base Tag
You learn something 'new' everyday. This isn't exactly new but it's new to me.
Today, at the CodeIgniter forums, xwero posted an alternative to doing the following:
<?php echo base_url() . 'css/styles.css ?>
The alternative was to use the HTML base tag, which was frankly the first time I've heard of such a tag.
The HTML Base Tag description is, &lquo;The <base> tag specifies a default address or a default target for all links on a page.&rquo;
As posted in the forums, a very useful usage for this is to use it as a base for css and the images folders.
<base href="<?php echo base_url() ?>"> <link type="text/css" rel="stylesheet" href="css/styles.css">
Categories: How To, Web Development
Tags: codeigniter, php
5 Comments
jayson
for css linking, I suggest using the html_helper that comes with codeigniter link_tag()
http://codeigniter.com/user_guide/helpers/html_helper.html
:D
nice site!
August 12th 2009
Teejay Obazee
@Charles Himmer. That’s right.
@jayson. I’ve never used the link tag before. I’ve always handled them with my own helper for bulk generating of link tags.
October 28th 2009
Greg
There’s a base tag?
October 28th 2009
Thorpe Obazee
Yep. Something I’ve obviously missed while playing with HTML at Geocities :)
November 11th 2009


Charles Himmer
Woah. That is pretty sweet and good to know. It would be nice not having to reference the base_url() function for every stinkin link or resource.
June 18th 2009