Float Added To Divs Not Working

I am trying to have three columns of text inside the DIV main-content. I added a class named “3col” with the properties of float: left; width: 200px; but it doesn’t work. Any ideas why?

LINK-
http://www.securehostserver.info/smokies/

Simple. CSS identfiers( classes or IDs) may NOT begin with numbers. change your class name to “cols_3” and you will see it work, for example. Hope that helps.

Sorry to butt in, but any idea why that is dresden? It’s not just CSS either, it seems to be in other scripting languages as well. I wanted to reference my 3D maze by “3d” but came up with so many errors that I changed it to “threed”

Why does a string not work if it starts with an int but will if it contains one? Is there a reason?

HTML5 allows ids to start with an integer although in css you would need to escape them to make it work.

As a matter of interest presently classnames in html can begin with a digit and you can do something like this which is valid html and cssa and works back to IE6.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style>
div.\\31{background:red}
div.\\32{background:blue}
div.\\33{background:yellow}
div.\\34{background:green}
</style>
</head>

<body>
<div class="1">test</div>
<div class="2">test</div>
<div class="3">test</div>
<div class="4">test</div>
</body>
</html>


More info on escaping css.

Wow, thanks Paul :slight_smile:

I did have a think why. I suppose it’s quicker to interpret and throw an error rather than check the following characters to make sure it’s either an int or string.