FBML CSS – Include CSS Into Your FBML Code
Working with FBML CSS can be tricky at times, so I’m here to show you all the ways you can successfully add CSS into your FBML code. Be warned though, there are a few ways and each way has it’s ups and downs. The usual down part of each set of CSS code is that if you create some complex CSS structure you’ll have it ‘hack’ it to work with Internet Explorer (any version). So that’s kind of a drag.
But lets get started with. We’ll cover these topics:
- Inline CSS
- External files
- Using inpage <style type=”text/css”> tag
- Caution of using the inpage method.
- Resource list for CSS (independent of FBML and Facebook)
Note: This isn’t a “how to program in CSS” guide. This is how to incorporate it with your Static FBML code and the like. So come knowledge of CSS/HTML is required.
Inline CSS – style=”"
This is the most basic way of using CSS. To do this, all you do is include style=….. into your styling tag.
So if we want to get some bold red text we would use the following code:
<span style="font-weight: bold; color: red;">Quantum Fanpage's bold red text</span>
And the output would be:
Quantum Fanpage’s bold red text
You can add the style= command to practically any html tag. What style options you can use and add change from tag to tag. For example, the SPAN tag will not accept (meaning it won’t work with) positioning nor height. A DIV tag is significantly more versatile.
External CSS Files
Using external files is probably the best solution, of course though you’d have to have your own server to host the files on. If you need some hosting just for your CSS files contact me via my main website and I’ll hook you up for free.
To use external CSS files you will first have to create a CSS file and host it somewhere. For example lets use sample.css. I have placed it on http://www.quantumfanpages.com/sample.css
The file contains this:
#sample-id-QuantumFanpages {
font-weight: bold;
font-size: 10pt;
color: red;
border 2px dashed red;
background: #111111;
width: 200px;
}
In order to use it we have to call and include the CSS file BEFORE everything else in the FBML code. So we put the FBML code at the top of our FBML page:
<link href="http://www.quantumfanpages.com/sample.css" rel="stylesheet" type="text/css" />
And then all we have to do it properly call/use the style, lets say in this sample div tag:
<div id=””sample-id-QuantumFanpages”>Quantum Fanpages other sample!</div>
The result would be something like this (I’ve cheated here to show you the desired effect since I cannot ‘just’ include the CSS file in the middle of a post … well I could, but it’s not fun, nor easy.):
So for your Fanpages, you have the change where the CSS file is. The template code is:
<link href="http://www.YOUR-SITE.com/CSS_DIRECTORY/sample.css" rel="stylesheet" type="text/css" />
Inpage <style type=”text/css”>
This method is a hit or more, unless IE shapes up and it sure as heck won’t work for older versions of IE. IE 8 just might work, dunno since I never use IE. (more on this later)
If for some reason you are not able to use external files, or Facebook changes the API again … you can use the ‘inpage’ css style. This is the idea of taking the external CSS file and having it all in the actual html/fbml. So it’s all one file/page instead of separate.
This is achieved in this easy way, again using the contents of sample.css as an example:
<style type="text/css">
#sample-id-QuantumFanpages {
font-weight: bold;
font-size: 10pt;
color: red;
border 2px dashed red;
background: #111111;
width: 200px;
}
</style>
After words all you have to do it call the style in the usual way.
Make sure to add that AT THE TOP of the FBML before any HTML code.
Internet Explorer has display problems when using <style type=”text/css”>.
Some older versions of IE, especially not patched version of IE6/7 can possibly NOT include the style. Though it’s said that recent revisions in the Facebook Fanpage FBML API have changed that.
Sooo, I highly recommend you test this on your own Fanpage. IE6/7 may or may not work with the <style …. you’ll just have to see.
But it might, so go ahead and use it for now. Most people say it currently works.
CSS Resource list.
If you’re going to add CSS to your Static FBML page, you’ll have to know CSS. Regular ol’ CSS. There is no difference between FBML CSS and regular CSS.
So with that in mind, here is a quick list of some pretty good CSS training material:
- Official W3C CSS learning Page. Full of CSS learning and training and tutorial material.
- CSS Zen Garden. A great place for learning how to create ‘perfect’ CSS.
- W3Schools CSS Tutorials. The one stop shop (well, not actually shop. It’s all free here) for all CSS material. It’s the first place I go to, to get any information about CSS.
If you have any other tips or tricks, let me know below and I’ll add them here while giving you credit. What do you think of this material? Leave a comment below!
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
Tagged with: <style type= • css • fbml • fbml CSS • Static FBML • style=
Filed under: FB 101 • FBML CSS • Static FBML
Like this post? Subscribe to my RSS feed and get loads more!

News, Updates, Free tips, Free Report ... what more can you ask for in a newsletter?
Hi! I have one little query. When I am using the href code, I am getting the entire code on clicking the hypertext link. For eg: (http://www.xyz.com) When I am clicking on the link (www.xyz.com) on the page, I am getting the entire link (http://www.xyz.com) dispalyed on the page. Could you please help me by letting me know why its happening?
Hey,
Sorry Shalz, but I don’t get your question. You mean the whole page loads in a new window or tab? If you want it to load INSIDE of your Static FBML then you will have to use IFRAMES.
Good luck!
Great stuff, I just can’t seem to get my whole web page to come out on my fbml? I’ll keep crackin at it! Thanls for the useful tips!
I am creating a new fan page. I’m still in the Getting Started mode. I successfully created and renamed a Static FBML page and added external CSS file link and HTML text. The div width is 520 pixels. The CSS file was validated and I can see the file when not on FB. On FB, in Edit Page, I enter the info,save the chanages, but nothing shows up on the page in either IE or Google Chrome. I out of ideas and open to suggestions.
Hi I have a question, I have a form in FBML, but I have 2 errors, 1. I load the background image I have only shows me the form and the form when I send him, I said you can not make the request to try again later, I can help, thanks.
this is that I’m using FBML
Nombre
Empresa
E-Mail
Mensaje
CSS is this
.main{
background: url(form.jpg); background-repeat: no-repeat; width:650px; height:700px;padding:80px;
}
.header{min-height:230px;
}
.form{
}
.header_form{
width: 80%; height: 300px;
}
Out of the FBML, if I work: http://creationandservices.com/AppFB/index4.html
Helly Enderson,
I’m not sure of the problem that you describe, though one quick error would be the URL for the background image. Since FBML is on the Facebook servers, you need the full URL to the image. So instead of:
background: url(form.jpg);
Use something like:
background: url(“http://www.yoursite.com/images/form.jpg”);
Use the full URL of where the image is hosted.
Hope that helps and sorry for the REALLY late reply,
– Piotr Krzyzek
HI can you show me the whole code Mixed :):) ??
Hey Moaazz? What do you mean by show you the whole code mixed? I’d be more than happy to show you the in’s and out’s of the code, I just need to know what you would like to see. :)
ello i hope u can help me pleaseeee
i wanted to use a fbml visible to connection code that will make only fan can view my page.this is the code
<a/
i needed the CSS to avoid empty space if not using it.But i didnt manaage and the white space still available.whats wrong?i had try to host my CSS file to google site n docs.im confused
Hey Tuah,
I don’t see any code there so I can’t help you. Hiding things from non-fans is actually rather easy. I explain it all in Quantum Fanpages Lite :).
Hello!
Very helpful thread.
I’m having an issue with my fan page where the image isn’t loading completely in IE…I’m calling it from an external CSS document, and I don’t know why this isn’t working! Help!
Thanks!