webdevRefinery Forum: <base> Tag - Purpose - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline brewster 

  • Group: Members
  • Posts: 17
  • Joined: 16-April 12
  • LocationTexas, USA
  • Expertise:HTML,Python

Posted 06 July 2012 - 02:50 PM (#1)

<base> Tag - Purpose


I may just be reading it wrong but I am not quite understanding tizag's explaination of the <base> tag. Can anyone clear it up?
0


User is offline NeilHanlon 

  • Group: Members
  • Posts: 884
  • Joined: 08-July 10
  • LocationRowley, Massachusetts
  • Expertise:HTML,CSS,PHP,Java,Graphics

Posted 06 July 2012 - 02:58 PM (#2)

It sets the url to base all relative URLs off of.

For example, if my site is at http://example.com/, but all my assets are located at http://static.example.com/, I can set my base href to http://static.example.com/, and then call images like so:

<head>
    <base href="http://static.example.com/" />
</head>
<body>
    <img src='assets/images/oh-hello.png' />
    <!--Actual link is http://static.example.com/assets/images/oh-hello.png-->
</body>

Thanks,
兄ニール

Website | Blog | @NeilHanlon | About.Me | Facebook | LinkedIn
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 06 July 2012 - 02:59 PM (#3)

Holy crap, what is this... oh cool. So instead of me having to constantly go
<a href='/my/full-path'>link</a>
to ensure that my link will work even if I move it do a different "folder" (controller) I could instead set my base to:
<base href="/">
but it doesn't work for images or anything else.
Reserved.
0


User is offline brewster 

  • Group: Members
  • Posts: 17
  • Joined: 16-April 12
  • LocationTexas, USA
  • Expertise:HTML,Python

Posted 06 July 2012 - 02:59 PM (#4)

View PostNeilHanlon, on 06 July 2012 - 02:58 PM, said:

It sets the url to base all relative URLs off of.

For example, if my site is at http://example.com/, but all my assets are located at http://static.example.com/, I can set my base href to http://static.example.com/, and then call images like so:

<head>
    <base href="http://static.example.com/" />
</head>
<body>
    <img src='assets/images/oh-hello.png' />
    <!--Actual link is http://static.example.com/assets/images/oh-hello.png-->
</body>


Ah ok. Thanks much.
0


User is offline arronhunt 

  • I'm a httpster
  • Group: Moderators
  • Posts: 3398
  • Joined: 09-March 10
  • LocationLos Angeles, CA
  • Expertise:HTML,CSS,Javascript,Graphics,Flash

Posted 06 July 2012 - 04:00 PM (#5)

Sounds like the beginning of HTML variables to me.
DO NOT OPEN THIS

Spoiler
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 06 July 2012 - 04:04 PM (#6)

View Postarronhunt, on 06 July 2012 - 04:00 PM, said:

Sounds like the beginning of HTML variables to me.

<div id="question" data-answered='false'>
  Variables in my markup? Logic in my templates?
</div>

Reserved.
1


User is offline soulcyon 

  • 兄貴 シャンク
  • Group: Members
  • Posts: 1591
  • Joined: 14-April 10
  • LocationNew Brunswick, NJ
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,Graphics,MongoDB,CouchDB

Posted 06 July 2012 - 07:15 PM (#7)

View Postarronhunt, on 06 July 2012 - 04:00 PM, said:

Sounds like the beginning of HTML variables to me.

Well this has been around for a very long time, so I'm not sure if that would serve any use.

I used the BASE href tag once before, and that was when I needed to do website-scraping. I downloaded all the HTML from another web page into my PHP script, but obviously I didn't want to download all the CSS/JS/IMG files that come along with it - so I just plug into a BASE tag to fix that up.
Posted Image
0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 748
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 07 July 2012 - 04:59 AM (#8)

Oh wow! I never knew about the base tag before! Cool stuff!

-----------

HTML variables would be cool! Although I don't see much point unless they could be dynamically updated (Javascript etc.).
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 07 July 2012 - 10:23 AM (#9)

View PostTheMaster, on 07 July 2012 - 04:59 AM, said:

HTML variables would be cool! Although I don't see much point unless they could be dynamically updated (Javascript etc.).

No they wouldn't! Why does a markup file need logic!
Reserved.
2


User is offline NeilHanlon 

  • Group: Members
  • Posts: 884
  • Joined: 08-July 10
  • LocationRowley, Massachusetts
  • Expertise:HTML,CSS,PHP,Java,Graphics

Posted 07 July 2012 - 10:27 AM (#10)

The only logic I have in my views would be along the lines of:

<?php
if(isset($message)):
?>
<div><?= $message ?></div>
<?php
endif;
?>

Thanks,
兄ニール

Website | Blog | @NeilHanlon | About.Me | Facebook | LinkedIn
0


User is offline markbrown4 

  • Group: Members
  • Posts: 388
  • Joined: 17-May 10
  • LocationMelbourne, Austraila
  • Expertise:HTML,CSS,Javascript,Ruby on Rails,Graphics

Posted 14 July 2012 - 09:09 AM (#11)

View PostTheEmpty, on 07 July 2012 - 10:23 AM, said:

No they wouldn't! Why does a markup file need logic!

I'd normally agree with you, but the proliferation of javascript templating frameworks makes me re-question these things.
Seen this? http://angularjs.org/
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 14 July 2012 - 09:26 AM (#12)

View Postmarkbrown4, on 14 July 2012 - 09:09 AM, said:

I'd normally agree with you, but the proliferation of javascript templating frameworks makes me re-question these things.
Seen this? http://angularjs.org/

I use Mustache, but I do that on the server side. That stuff should be done on the server side too. If your page is dynamic, you got a server that can render a template.
Reserved.
0


User is offline markbrown4 

  • Group: Members
  • Posts: 388
  • Joined: 17-May 10
  • LocationMelbourne, Austraila
  • Expertise:HTML,CSS,Javascript,Ruby on Rails,Graphics

Posted 14 July 2012 - 09:45 AM (#13)

Consider this thread Hijacked.

View PostTheEmpty, on 14 July 2012 - 09:26 AM, said:

I use Mustache, but I do that on the server side. That stuff should be done on the server side too. If your page is dynamic, you got a server that can render a template.

The times, they are a changin'
http://lea.verou.me/...do-client-side/

The client-side is where all of this kind of processing is heading, I'm not sure I agree with all of it. It's still the wild west.
But, there's no doubt a huge amount of work is being done in this area of client-side templates / frameworks.

Backbone, Ember, Knockout, Angular etc..

I've been using Backbone for a little while now, when you start using it you can see certain patterns and why things like client-side templates work. Coupled with a way to deal with models over a REST JSON API it's pretty pleasant to work with.
And the UI is much more responsive as it's all downloaded in the scripts at the start.
The only thing you need to deal with the server for are small JSON updates.
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 14 July 2012 - 10:12 AM (#14)

She says you can't localize, Twitter does that client side.
Reserved.
0


User is offline callumacrae 

  • {{ post.author }}
  • Group: Members
  • Posts: 2862
  • Joined: 20-January 11
  • LocationWarwickshire, England
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 14 July 2012 - 10:39 AM (#15)

Thin server ftw
Front-end developer and writer
Twitter | GitHub | phpBB Contributor and Website Team Member | lynxphp
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 14 July 2012 - 10:46 AM (#16)

View Postcallumacrae, on 14 July 2012 - 10:39 AM, said:

Thin server ftw

More into unicorn.
Reserved.
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services