Is there a way to store color info (like rgb and hex) as global variables in html? I'm working on this website, and it's got maybe 10 or 20 thousand tables, most with the same bg color. The last thing I want to do is go through all of them and change the colors cause of one stupid mistake (and it's more convenient than global find/replace).
Announcement
Collapse
No announcement yet.
HTML: global variables
Collapse
X
-
HTML doesn't have variables. Period.
It's a markup language, not a programming language.
What you probably want is a scripting environment of some kind (PHP could do that no problem), or CSS somehow."The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
-
If you're already using PHP, just use a PHP variable.
Then use "$color" everywhere and define it once at the top."The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
Comment
-
You can do it with CSS. Suppose (for some reason) you want all cells in bright red. Either in the head of your document, or better, in a external css file, write:
td {background-color: #ff0000}
All table cells in linked documents wil then be red. You can override indivudual cells with by using the CLASS attribute to link another style or using an inline style:
<td align="center" width="45" style="background-color: #ffff00">Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...
Comment
-
I think I'll go with the php approach
I allready have a mile long css file, an all the tables are slightly different- don't want to go around with
and then have to redefine class for each table.Code:td {blah: "" etc} .{} .{} .{} .{}
Lets see how this works.cIV list: cheats
Now watch this drive!
Comment
-
You can do the same thing for any element, it doesn't have to just be TD.
Ten to twenty thousand tables. Man, and I thought my work was hard.
Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...
Comment
-
CSS is bloody simple.
On the one hand, if you're more comfortable with PHP, go with it. On the other hand, you do need to keep in mind future developers. My current task is ripping out a bunch of brilliant JavaScript that no one here at the company can understand. It functions very well, but since we can't understand it (it's extremly complex and well over 1200 lines), we can't modify it. It's been around for three years, and none of the developers here was here when it was written.Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...
Comment
-
Mea culpa, read too quickly.Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...
Comment
-
Alternatively, you could create variables using JavaScript.
Just giving you options.Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...
Comment
-
I said at least. We really don't know how long it was, because it was all wrapped up into one long line. 1200 was where I got to before I was told to drop it.Originally posted by Asher
1,200 lines of JavaScript is a challenge?
Go here: http://www.acuvue.com/
Those twelve hundred+ lines of code control the buttons in the left side navbar. A couple rollovers, and a flyout menu? I could (and will) do the same with about 50 lines of code.Christianity: The belief that a cosmic Jewish Zombie who was his own father can make you live forever if you symbolically eat his flesh and telepathically tell him you accept him as your master, so he can remove an evil force from your soul that is present in humanity because a rib-woman was convinced by a talking snake to eat from a magical tree...
Comment

Comment