Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Thursday, November 19, 2009

How to use CSS to style code snippets

It is easy to use CSS to style code snippets, as shown in Figure 1.

[caption id="attachment_2836" align="alignnone" caption="Figure 1: Sample output of CSS style for code snippets"]Figure 1: Sample output of CSS style for code snippets[/caption]


Step 1: Append this code inside a style sheet.


pre{ font-size:12px; background:#fff; border:1px solid #000; line-height:20px; width:600px; overflow:auto; overflow-y:hidden; margin:0; padding:0; } pre code{ font-family:Monaco,Courier; display:block; margin:0 0 0 40px; padding:18px 0; } 

Step 2: Put the code snippets inside <pre> and <code> tags.


<pre><code>def f(): txt = "Some sample code" return txt </code></pre>

Saturday, March 7, 2009

Valid ampersand when writing URLs in HTML

Always use &amp; in place of & when writing URLs in HTML.

Example of invalid ampersand for URL in HTML:
<a href="test.php?var1=3&var2=6&var3=10">...</a>

The correct usage:
<a href="test.php?var1=3&amp;var2=6&amp;var3=10">...</a>

To validate for markup, please use W3C Markup Validator.

Monday, August 18, 2008

9 ways to hide affiliate links

These codes are useful for hiding the affiliate links. However, please read the affiliate program terms of service, so that you won’t go against it.

For all except the last way (.htaccess redirect), create the respective file for each affiliate link with the code for the chosen redirect style. Replace ‘http://your-affiliate-link-goes-here’ with the URL of the affiliate link.

For example, if you choose to use the PHP redirect, first create a PHP file. Copy and paste the PHP redirect code into that file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL.

Every time you want to link to the affiliate link, just link to that file.

You have to create new file for each affiliate link.

HTML redirect

<html>
<head>
<title>HTML Redirect</title>
<meta http-equiv="refresh" content="0;
url=http://your-affiliate-link-goes-here">
</head>
<body>
Please wait. Redirecting...
</body>
</html>


PHP redirect

<?php header("Location: http://your-affiliate-link-goes-here"); ?>


ASP redirect

<%@ Language=VBScript %>
<% Response.AddHeader "Location","http://your-affiliate-link-goes-here" %>


ASP.NET redirect

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.AddHeader("Location","http://your-affiliate-link-goes-here");
}
</script>


Coldfusion redirect

<.cfheader name="Location" value="http://your-affiliate-link-goes-here">


JSP redirect

<% response.setHeader( "Location", "http://your-affiliate-link-goes-here" );
response.setHeader( "Connection", "close" ); %>


cgi Perl redirect

$q = new CGI; print $q->redirect("http://your-affiliate-link-goes-here");


Ruby on Rails redirect

def old_action redirect_to "http://your-affiliate-link-goes-here" end


Apache .htaccess on Linux

Add this code to the end of .htaccess file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL. To have more than one affiliate link, just add another RewriteRule.
RewriteEngine on RewriteRule ^affliate.php$
http://your-affiliate-link-goes-here [R]