Jump to content

[SOLVED] 404 as a Class / ID Identifier


dave_sticky

Recommended Posts

Hi guys,

 

I came across an interesting issue that I'm not sure I understand. Working on CSS for a website, I wanted to apply a class to an ID box. So...

 

// The CSS

#content {
display: block;
position: relative;
float: left;
width: 300px;
height: 10px;
border-width: 1px;
border-style: solid;
}

#content.404 {
border-color: #990000;
}

#content.blah {
border-color: #990000;
}

// The HTML

<div id="content" class="blah"></div>
<!-- The above will give me a box with a red border, but... -->

<div id="content" class="404"></div>
<!-- That one gives me a box with a black border. They should be the same (ie, red). -->

 

Does anyone have any idea why this would happen? Can CSS not handle certain characters when defining classes?

 

Just a bit confused, as it took me about 45 minutes to realise this was happening, and I'd quite like to know what the problem is! Any thoughts very much appreciated.

 

Thanks,

 

Dave

 

 

Link to comment
Share on other sites

Perhaps this is what your referring to...

 

In CSS1, a class name could start with a digit (".55ft"), unless it was a dimension (".55in"). In CSS2, such classes are parsed as unknown dimensions (to allow for future additions of new units). To make ".55ft" a valid class, CSS2 requires the first digit to be escaped (".\35 5ft")

 

Source: http://www.w3.org/TR/CSS21/grammar.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.