CSS and hexadecimal values
Now then, I've just started sinking my teeth into CSS, finding it pretty straightforward so far, which is great.
But I have come across one stumbling block. I've found that if I try to set a hexadecimal value as the colour for my background (like this: body{ background-color: #6969
Megan posted this at 14:10 — 24th July 2010.
She has: 11,421 posts
Joined: Jun 1999
Hi Shelmerdine,
Looks like your post got cut off there. Could you fill us in with the details? I'm sure several people would be happy to help.
Shelmerdine posted this at 13:11 — 26th July 2010.
They have: 4 posts
Joined: Jul 2010
Ok, this is weird, I tried to post the details again, but it got cut off at the same point. The site doesn't like the code at all.
I was trying to use a hexadecimal value in CSS as a background colour, but it wouldn't work and it also reset all the other attributes in the CSS document. Font size and color and suchlike all stopped working when the piece of code was in place. Yet the same piece of code works perfectly well in html. Any idea why this might be?
The value was: #6969BEBE2121
Megan posted this at 17:19 — 26th July 2010.
She has: 11,421 posts
Joined: Jun 1999
Try surrounding your code with <code> tags. That should prevent anything from being cut off.
That's not a proper hex value that you posted above, it has 12 digits instead of 6. Something's going wrong at that point in your stylesheet, meaning that the browser will ignore everything that comes after that. I'm not sure if an improper hex value would do that.... forgetting to finish with a semi-colon would.
Megan
Connect with us on Facebook!
cools4u posted this at 10:36 — 18th September 2010.
They have: 10 posts
Joined: Sep 2008
valid hexadecimal value can be of six characters only after "#" like : "#ffff00", "#ddgghh", "#7698dd"....you have not define a valid value for background color....
tuneup2011 posted this at 05:23 — 5th October 2010.
They have: 1 posts
Joined: Oct 2010
I was trying to use a hexadecimal value in CSS as a background colour, but it wouldn't work and it also reset all the other attributes in the CSS document. Font size and color and suchlike all stopped working when the piece of code was in place. Yet the same piece of code works perfectly well in html. Any idea why this might be?
{links removed}
Megan posted this at 14:56 — 5th October 2010.
She has: 11,421 posts
Joined: Jun 1999
Can you show us the exact code you used? Browsers will stop parsing CSS if they encounter something invalid. In the example above, the colour value had more than 6 digits. A hex value must also begin with a #, and the declaration must finish with a semi-colon. Your code should look like this:
background-color: #666666;
CSS does accept shortened, 3-digit codes, such as #666 (this expands to #666666).
Megan
Connect with us on Facebook!
andolasoft posted this at 14:28 — 26th October 2010.
He has: 13 posts
Joined: May 2010
please provide your css code of support. It may well might be having some syntax error.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.