Got this idea from a good source and I need a backup for when I would need it.
1. Token: ~sitecollection ~site
2. SharePoint Server Token <% $SPUrl:~sitecollection/...%>
3. Emedded Code: <%=SPContext.Current.Site.ServerRelativeUrl %>
You can use the embedded code any where in application page and web parts but don't use it in master page and page layout even though they seem work, because master page and page layout can be customized. The embedded code is only allowed in the uncustomized pages.
4. SharePoint Control:
You can use the value returned by this control as control attribute but this is more like an hack, but it works.
If you don't want to use it directly in attribute, you can use asp.net literal.
<a href="
<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/_layouts/MortalityDB/css/custom.css %>" runat="server" after="SharepointCssFile"/>
Here is when to use which option with different controls
1.
The only way it works for ScriptLink is the token ~sitecollection
<SharePoint:ScriptLink ID="ScriptLink2" language="javascript" name="~sitecollection/_layouts/TestScript1.js" OnDemand="true" runat="server"/>
2.
Use ScriptLink to include JavaScript in SharePoint. If you have to use
Comments