CSS tricks in practiceIn order to show you how it's done, this page contains some CSS tricks in practice. Save the page and the related CSS file, fooledya.css (right click and choose Save as) into a directory on your hard drive. Then look at the page. It will look pretty similar to what you're seeing now. Now, move the fooledya.css file to another directory and look at the page again. You should see a somewhat different page - some words should be in bold, some should be in italics and so on. You'll also see one heading gain in size and another shrinking. Some links should appear. That is what the spider, who does not understand CSS, sees when it looks at this page. If this sentence is in red, you're not seeing what the spider would see because the CSS is still in memory. In that case, make sure you have moved the fooledya.css file into another directory, reboot your computer and look at this page on your hard drive again. Now, you've seen the effect, let's take a brief look on how it was done. Hopefully you spent some time reading the CSS tutorials I listed on the CSS tricks page, if not, you might want to at least take a quick look at them before continuing. What I've done with this page is pretty basic stuff and shouldn't be very difficult to understand to anyone who knows CSS. However, people who are completely new to CSS might have some problems, so make it easy on yourself and read the tutorials. But let's get on with the business and take a look at the external CSS file. The CSS file looks like this:
.swapmenu a:active { text-decoration: none; color: blue } OK, now let's see what it does. Everything beginning with .swapmenu are just commands I use to make the menu on your left a little more attractive. For example, one of the .swapmenu's makes a link in the menu turn its color into cyan as you move your mouse over it (sorry Netscape-guys, only works with IE). So ignore everything beginning with .swapmenu as unrelated to the tutorial. We're left with:
SPAN a:active { text-decoration: none; color: black } The four lines beginning with SPAN at the top define attributes to the links. While links outside <SPAN> tags will look normal, links inside <SPAN> tags will have no underline and will be colored black. Since the text color of this document is black, that makes the links practically invisible. You can still spot them if you move the cursor over one of the links, as the cursor turns from an arrow into a hand. However, the chance of that happening is relatively low if the document is long and contains only a couple of these hidden links.
.bold { font-weight: bold; font-style: normal } Creates text that looks bold to the visitors, but not to the spiders. A class="bold" statement is required: <SPAN class="bold">Bold text</SPAN>. The .italic rule works the same way, but it creates text in italics. Both classes can also be used with other HTML tags than SPAN (such as the P tag), but since SPAN does not carry any special weight in search engine algorithms and doesn't have any use in normal HTML, it suits perfectly for the job. .red { color: red } Makes that telltale line near the top red if this CSS file is present. Otherwise unrelated to the subject.
.hideattr B { font-weight: normal; font-style: normal } Makes all text inside B and I tags look like regular text instead of bold and italics. The search engine spiders still regard everything inside B and I tags to be in bold and italics. As this whole article is within a table, the .hideattr rule is included in the TD statement near the top of the HTML code. Thus, it applies to everything in this article, but does not screw up the menu on the left, which uses a B tag in its construction. H1 { font-size: xx-small; font-weight: normal; font-style: normal } Defines the size of all H1 headings as minimal to the visitors. Spiders still think they see a big heading and will value text inside it accordingly. That small "CSS tricks in practice" text up there near the top is a regular H1 heading, believe it or not. .heading { font-size: x-large; font-weight: bold; font-style: normal } Enables the creation of authentic-looking fake H1 headings, if someone wants them. They look normal, but don't get as much weight from the search engines as regular H1 headings do. Useful, if you need to have a heading but are unable to get your main keywords in it. Used in this document with the SPAN statement, but can also be used with other HTML commands. Hopefully this little article has managed to show how you can use CSS to your advantage when optimizing your pages. |
|
Directories |