Posts Tagged ‘css’

How to use the heading tag to improve search engine listings

In HTML there are few tags as important as the <h1> tag. It is literally the heading for your page and when we talk about how to structure a document, we’re taught that the <h1> tag should represent the title of the document.

Common Mistakes

Having more than one H1 per page.

A web document can have only one title, and that’s what the H1 tag is meant to be. Instead of having more than one, use the <h2> tag and stylize it with CSS.

Using the H1 tag because you like the font size

The H1 tag is big because it’s meant to be important not because people think it’s pretty. As will all HTML elements, you can use CSS to change the look and feel of tags easily. For example:

[source lang="html"]
<h1>Test Title</h1>
<h2>Test Title Two</h2>
<strong>Test Strong</strong>
[/source]

 

[source lang="css"]
h1,h2,strong {
font-size: 100px;
font-weight: normal;
}
[/source]

Using the code above will make all H1,H2 and strong (bold) tags throughout a website look identical.

 

Using the same H1 throughout the site

The purpose of the H1 tag is … as I’ve said to represent the content of a specific page so it’s important that the contents of your heading are unique for each page.

Using the H1 for the wrong content, or not using it at all

If the purpose of a heading tag is to highlight the heading (or title) of the document, then not including one at all will result in search engines being unable to properly understand your content.

Using Heading Tags to separate content

Let’s take a look for example at a simple piece of Lorem Ipsum to see how search engines may see your content with (and without) proper headings.

Example One : No Formating

As you can see from this example, it’s nearly impossible to determine what text is important and which is worthless in this post.

[source lang="html"]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sapien nulla, malesuada eu, tincidunt eu, dapibus sed, risus. Curabitur rutrum velit non enim. Duis congue, neque non pharetra blandit, est lectus aliquet purus, id dapibus augue lacus sed sem. Aliquam erat volutpat. Ut hendrerit sapien vitae lacus. Duis libero lectus, varius sit amet, auctor ut, mattis id, magna. In hac habitasse platea dictumst. Aliquam libero neque, interdum id, dignissim id, fermentum eget, tellus. Aliquam eget lorem quis nibh fermentum egestas. Duis id ante sed ligula egestas malesuada. Maecenas pharetra mollis ipsum. Vestibulum dignissim, turpis vel luctus facilisis, dolor mi gravida nisi, ac suscipit enim ipsum vel elit. Aenean mauris purus, convallis ac, pellentesque suscipit, varius in, lacus. Morbi blandit odio quis libero. Nullam gravida rhoncus massa. Fusce ullamcorper. Phasellus sapien nibh, consequat eu, semper in, pretium in, dui. Vivamus scelerisque.
[/source]

Example Two: Simple Text Formating

Now, with paragraph breaks, we can at least start to understand the format but not what is important.

[source lang="html"]

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Sed sapien nulla, malesuada eu, tincidunt eu, dapibus sed, risus. Curabitur rutrum velit non enim. Duis congue, neque non pharetra blandit, est lectus aliquet purus, id dapibus augue lacus sed sem. Aliquam erat volutpat. Ut hendrerit sapien vitae lacus. Duis libero lectus, varius sit amet, auctor ut, mattis id, magna. In hac habitasse platea dictumst.

Aliquam libero neque, interdum id, dignissim id, fermentum eget, tellus.

Aliquam eget lorem quis nibh fermentum egestas. Duis id ante sed ligula egestas malesuada. Maecenas pharetra mollis ipsum. Vestibulum dignissim, turpis vel luctus facilisis, dolor mi gravida nisi, ac suscipit enim ipsum vel elit. Aenean mauris purus, convallis ac, pellentesque suscipit, varius in, lacus. Morbi blandit odio quis libero. Nullam gravida rhoncus massa. Fusce ullamcorper. Phasellus sapien nibh, consequat eu, semper in, pretium in, dui. Vivamus scelerisque.
[/source]

Example Three: Formating with Headings

Using both paragraph formating and headers:

[source lang="html"]
<h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</h1>

Sed sapien nulla, malesuada eu, tincidunt eu, dapibus sed, risus. Curabitur rutrum velit non enim. Duis congue, neque non pharetra blandit, est lectus aliquet purus, id dapibus augue lacus sed sem. Aliquam erat volutpat. Ut hendrerit sapien vitae lacus. Duis libero lectus, varius sit amet, auctor ut, mattis id, magna. In hac habitasse platea dictumst.

<h2>Aliquam libero neque, interdum id, dignissim id, fermentum eget, tellus.</h2>

Aliquam eget lorem quis nibh fermentum egestas. Duis id ante sed ligula egestas malesuada. Maecenas pharetra mollis ipsum. Vestibulum dignissim, turpis vel luctus facilisis, dolor mi gravida nisi, ac suscipit enim ipsum vel elit. Aenean mauris purus, convallis ac, pellentesque suscipit, varius in, lacus. Morbi blandit odio quis libero. Nullam gravida rhoncus massa. Fusce ullamcorper. Phasellus sapien nibh, consequat eu, semper in, pretium in, dui. Vivamus scelerisque.
[/source]

As you can see, using the heading tag properly in example three allows us to clearly see a separation of content and allows robots such as Google to properly crawl and identify the critical areas of our websites.

You may also care to watch the video Does it matter what order you put header tags in?

Five simple things I did to increase traffic to my website.

When I started thisismyurl.com I didn’t have a loyal base of visitors, in fact I barely had a trickle of traffic. For the first month, I only received a couple visitors each day but now, five months after launching my website I receive a few hundred unique visitors everyday. Still not huge numbers but it’s a start right?

I follow five simple rules that I believe helped me build a successful website, five rules that everybody can follow.

  1. I posted simple, honest content. Most the content on my website is designed for people with little technical expertise who need to solve a problem. This is an easy way to generate traffic, find a problem and help people solve it.
  2. I posted content often. While I was building my website traffic I often posted content twice a day to help establish new visitors, then once I knew people had taken the time to read my posts I began posting less frequently but with more focus on content.
  3. I posted what people wanted. I spend a lot of time looking at the stats for my website and I know what articles people read and which are worthless. The articles people read inspire me to write more (better) content on similar subjects while the less popular posts are reviewed and improved.
  4. I posted different kinds of content. When I started out I made a lot of mistakes (and still do) but by testing different content styles, I’ve learnt the proper length for many posts and how to make them more readable for the audience.
  5. I posted what I knew about. Instead of trying to chase trends or break news stories, I posted content designed to help business owners make better websites, a lot of it is still pretty technical but it’s getting more ‘people’ friendly everyday.

What I’ve learnt over the past five months is that people love free stuff. My post popular page by far is Fundraising Thermometer Plugin for Wordpress a free plugin for WordPress designed to help charities display their current fundraising level. My second most popular post is another WordPress plugin called WordPress Plugin to automatically update the copyright notice., a simple post to allow the display of copyright details on a post. Other popular posts on my blog have been:

  1. How to center content with CSS and HTML
  2. No More Frames Plugin for WordPress
  3. Code Free Pong
  4. How to make awesome 3d icons in Adobe Fireworks
  5. How to create a reflective website image in Photoshop

As a website owner, the best way for you to increase your website traffic is to understand what people want and give it to them. This might sound like common sense logic but often times we as business owners (because my website really is a business) forget that serving content is about the reader, not the writer.

Happy five months of reading my website, I look forward to another great month writing.

Hyper linking in Dreamweaver

HTML is all about something called Hyper Linking. Actually, that’s what the first two letters of HTML pretty much stand for … Hyper Text Markup Language but what does it actually mean? Well, oddly enough us geeks are not all that tricky to understand, give us a beer mug shaped like Yoda’s head and let us string together a few acronyms and we’re happy.

Hypertext is text on a page that contains a Hyper Link

A Hyper Link is a piece of text or graphic which links to another document. When a user clicks the Hypertext, they follow the Hyper Link to the new document. Not brain surgery but I completely understand how most people would never need to know that.

Using Hyper Links in Adobe Dreamweaver is, for the most part dead simple. To insert a hyperlink into your Dreamweaver document, simply ensure you are in Design mode and select the text you want to make a hyperlink. Next, using the Property toolbar, type the website address you’d like to link to.

How to make a hypertext link in Dreamweaver

How to make a hypertext link in Dreamweaver

There are actually several things you can do with a hyperlink, called protocols. Most people only ever know about the http:// protocol (the Hyper Text Transfer Protocol) but there’s also a ton of other protocols people could use including the https://, ftp://, mailto://, gopher:// and of course the nntp:// protocol. If you have no idea what these are, congratulations … you’ll almost never need to care in your life unless you’re a hard code web developer.

Once you’ve added an http:// link using Dreamweaver you can also force the clicked link to open in a new web browser simply by adding the phrase _blank to the Target field of your property bar. There are a couple of other neat tricks with anchor tags people should be aware of, but to accomplish them we’re going to have to switch to Code view in order to see the following code:

[source lang="html"]<a href="http://www.thisismyurl.com">This is my Hypertext.</a>[/source]
In addition to the href value (where the click will go), you can also add:

  • accesskey to make the link a keyboard shortcut
  • class to assign a CSS class
  • dir (rtl or ltr) to make the text run right to left or left to right
  • id to make the anchor text have a proper name
  • lang to assign a language value
  • style to format the tag
  • tabindex to index the tab order for the link
  • title to assign a title tag
  • rel for the link relationship.

Of these I would recommend most links on a website have an href value to show where people should go, an ID if it’s a critical link, a rel for defining relationship values and the title for SEO value. Typically then, a link should look like:

[source lang="html"]<a rel="nofollow" title="My Great Website" id="mainlink" href="http://www.thisismyurl.com">This is my Hypertext.</a>[/source]

Absolute Paths vs. Relative Paths

One of the great debates in web publishing is the choice between using absolute paths vs. relative paths. An absolute path is one which is mapped completely to the final destination (http://www.thisismyurl.com/tutorials/placing-page-content-in-adobe-dreamweaver/) vs. one that is linked relative to the document you’re currently reading (../placing-page-content-in-adobe-dreamweaver/) the main advantage of an absolutely path is that it’s locked, while the main advantage of a relative path? That’s it’s relative … in the end, it doesn’t matter so long as the link works.

This tutorial is part six in a ten part series.
  1. Preparing a website in Adobe Dreamweaver
  2. Building your first Dreamweaver Template file
  3. Structuring your website with Adobe Dreamweaver
  4. Improving the common elements in Dreamweaver
  5. Placing page content in Adobe Dreamweaver
  6. Hyper linking in Dreamweaver
  7. Working with Images in Adobe Dreamweaver
  8. Adding Cascading Style Sheets with Dreamweaver
  9. Putting your website on a remote web server with Adobe Dreamweaver
  10. Adding Google Analytics to your Dreamweaver Template

Using CSS to highlight a link

Now you know how to add a really cool hidden link in CSS but what about if you want to make certain links stand out? Just as easy

First, when you add a link to your website we want to assign a class to it like so:

<a href=’http://www.thisismyurl.com’ class=’standout’>

In my case, I’ve labeled this link with the special tag standout which will let me affect the appearance. Next in the CSS, let’s add a special rule for it:

a.standout {
/* this is what we want the normal link to appear as */
text-decoration: none;
font-color: #990000; /* (assuming you want your link blood red */
font-weight: bolder;
}

a.standout:hover {
/* when people mouse over the link */
font-color: #000000; /* (assuming your default text is black) */
cursor: default;
text-decoration: underline;
}

In this example, I’ve made the link red but still taken the underline away. I’ve put the underline back when you mouse over the link which calls extra attention to it and shows the user there’s something interactive with the link.

How’s it work? Pretty simple really, any time your HTML calls an <a> tag with the class standout, the CSS will be loaded and in turn change the appearance of your site to accommodate the new new.

Using CSS to disguise a link.

Sometimes on a website we want to link to another section for Google or other robots but we don’t want to distract our users with too many links, how do we do it? Cascading Style Sheets and a little HTML knowledge.

First, when you add a link to your website we want to assign a class to it like so:

<a href=’http://www.thisismyurl.com’ class=’noshow’>

In my case, I’ve labeled this link with the special tag noshow which will let me affect the appearance. Next in the CSS, let’s add a special rule for it:

a.noshow {
     /* this is what we want the normal link to appear as */
     text-decoration: none;
     font-color: #000000; /* (assuming your default text is black) */
}

a.noshow:hover {
     /* when people mouse over the link */
     font-color: #000000; /* (assuming your default text is black) */
     cursor: default;
}

As you’ll see since rules cascade from in a logical order, the text-decoration rule automatically applies to the hover state since it applies to the normal state but since hover states have their own color, we have to redefine it.

There you go … now you can put links on your website that nobody knows are there.

Turning your menu list into menu buttons

menu1 Turning your menu list into menu buttons imageOver a couple of tutorials I showed you how to turn a simple list like the one here into a horizontal menu and how to add rollover effects to that menu so that your list items made it clear to users that they could click them.

Now, let’s take a look at using some simple CSS tricks to turn your list items into menu buttons.

The HTML

menu2 300x97 Turning your menu list into menu buttons imageWe’re going to use some pretty basic HTML to accomplish this task:

<div class=’menu’>
<ul>
<li><a href=’index.php’ title=’Home’>Home</a></li>
<li><a href=’about.php’ title=’About Me’>About Me</a></li>
<li><a href=’contact.php’ title=’Contact Me’>Contact Me</a></li>
</ul> 
</div> 

The CSS

The CSS to create the buttons is found entirely in the <li> functions of the CSS, with only minor modifications to the CSS used in our last tutorial for the a:hover and a:action state.

.menu ul {
list-style: none; /* removes the • from the list items*/
text-align: center; /* centers the list items */
}

.menu li {
font-family: “Lucida Sans”, Arial, Helvetica, Geneva, sans-serif;  /* sets the font of the menu */
font-size: 12px;  /* sets the size of the font */
display: inline;  /* makes the menu items float beside each other */
margin: 0px 10px 0px 10px;  /* leaves 10px of space between the items */
font-weight: bolder;  /* makes the font bold */
background-color: #999999;  /* sets the background to dark grey */
padding: 5px;   /* adds some space around the words */
border: 1px solid #000000;   /* makes the border black */
}

.menu a:link {
color: #000000;  /* hyperlink color is now black */
text-decoration: none;   /* remove the underline */
}

.menu a:hover {
color: #cccccc; /* change the color to light grey */
}

.menu a:active {
color: #ffffff;  /* change the color to white */
}

There you have it, a horizontal menu with rollovers using just HTML and CSS.

Adding Rollovers to your HTML without JavaScript

In my last tutorial I showed you how to build a simple horizontal menu in HTML with only a few lines of CSS. Let’s take that same HTML code and use it to increase usability and improve the overall look of your site.

The HTML

This is the same HTML used in our last article:

<div class=’menu’>
<ul>
<li><a href=’index.php’ title=’Home’>Home</a></li>
<li><a href=’about.php’ title=’About Me’>About Me</a></li>
<li><a href=’contact.php’ title=’Contact Me’>Contact Me</a></li>
</ul> 
</div> 

The CSS

In CSS there are a few different states an anchor tag (<a>) can be. You can be:

 

  • a:link – the default state
  • a:visited – after you’ve been to the page
  • a:active – after you’ve clicked it but before you’ve left the page
  • a:hover – when your mouse is over the link

 

To make a page truly optimized for usability we can change the state these menu items appear in.

.menu a:link {
text-decoration: none;
color: #FF0000;
border-bottom: dotted 1px #FF0000;

newmenu 300x72 Adding Rollovers to your HTML without JavaScript imageThis CSS changes the color of the links to Red (#FF0000) and removes the underline from the links. Personally, I don’t like the default underlines so I like to replace them with a dotted line instead.

Next we want to assign a special event when the user has placed their mouse over one of your text items. To do this, we affect the a:hover CSS. Also, while I’m in there I am going to add a special event to the a:active CSS which will change the color when the user clicks the link but before they leave the page. This ensures they know they’ve clicked the link.

.menu a:hover {
color: #0000FF;
border-bottom: dotted 1px #0000FF;

.menu a:active {
color: #00FF00;
border-bottom: dotted 1px #00FF00;

Using the two states above, the user is now aware that they’ve entered a clickable zone because the link changes color and when they click the option, it changes color again to let them know they’ve clicked. There you go, three simple CSS commands to make your page more usable.

Using CSS to build a horizontal menu

picture 11 300x192 Using CSS to build a horizontal menu imageOne of the most common questions I get asked is how to build a simple menu like the one at the top of my website, using pure HTML and CSS. Actually it’s wonderfully easy and I’m happy to share the process with you.

The HTML

First, you’ll need to write the proper source HTML for the menu to work. I use unordered lists <ul> with list item <li> tags to build the menu items, this is in keeping with web standards and ensures compatibility across multiple devices.

The code a typical menu should look something like this:

<div class=’menu’>
<ul>
<li><a href=’index.php’ title=’Home’>Home</a></li>
<li><a href=’about.php’ title=’About Me’>About Me</a></li>
<li><a href=’contact.php’ title=’Contact Me’>Contact Me</a></li>
</ul> 
</div> 

The CSS

Now, with the basic HTML out of the way we have to take a look at the CSS codes we need to make the menu work, and how each of the does it.

We want to define the menu as a class, not an ID since we might want to reuse the code in both the header and the footer. An ID can only be used once on a page, were a class can be used multiple times. There is no actual code for the menu tag, it’s just a holder for us.

The <ul> tag on the other hand needs to be altered. To do this, we add the following code:

.menu ul {
list-style: none;
text-align:center;
}

Simply put, let’s get rid of the bullet (•) and center the content. Next we need to tell the <li> tags to sit side by side instead of appearing as a list, and we need to make sure they don’t bump into each other.

.menu li {
display: inline;
margin: 0px 10px 0px 10px;
}

There we have it, a table-less menu which appears in the center of your site in just a few lines of CSS.

How to center content with CSS and HTML

All too often I’ve found inexperienced designers using <table> tags to center content on a website, they always have the same reasoning and while I appreciate they didn’t know the proper way to do it, that’s no excuse.

First, let’s all accept that <table> tags are designed for one thing and one thing only … tabular data. You wouldn’t use a spread sheet to design a business card, so don’t use a table to design a website.

Now, if you’d like to center a website across all browsers there’s a few things that you’re going to need to do.

The HTML

First, in your HTML you need to create some <div> containers. Here’s all you need:

<body>
<div id=’container’>
Content
</div>
</body>

The CSS

Next, you need to write the CSS code to center your content:

body {
text-align: center;
}

#container {
margin: 0px auto 0px auto;
text-align: left;
width: 80%;

There you go, that’s all you need to center a page using pure HTML and CSS.

How does it work?

The CSS file instructs the <body> tag to center the content using the text-align option. Then, it tells the <div> tag named container to do three things:

  1. Set the margins to nothing at the top and bottom but automatically find the right and left. In CSS this is represented by margin: top right bottom left.
  2. Next, realign the text to the left. Since we’re using Cascading Style Sheets the effect of the earlier text-align: center would otherwise affect our text.
  3. Finally, set the width of our page container to 80%.