14 replies [Last post]
needy
Offline
Enthusiast
australia
Last seen: 12 years 43 weeks ago
australia
Timezone: GMT-1
Joined: 2007-06-11
Posts: 95
Points: 0

Hi -
I have a site in which the artist wants a different photo of himself in the header of each separate page which represents a decade. I have achieved this with a separate css for each decade...but that seems so bulky. Is there another way to do it?

click on the decades on the home page and see the photos change in the upper right corner. the site
cheers,
Needy

liam.smart
Offline
Enthusiast
Dundee, Scotland
Last seen: 12 years 34 weeks ago
Dundee, Scotland
Joined: 2008-06-26
Posts: 164
Points: 0

Easy! Just give the header

Easy! Just give the header (or container) a different class on each decade. ie. 'one', 'two', 'three' etc...

Then keep your header styles as they are but just over-ride them with the following styles:

.One #header {charouxstyle.css (line 29)
background:#FFFFFF url(../images/jaques/jaques_colour_image1.jpg) no-repeat scroll 98% 50%;
}
 
.Two #header {charouxstyle.css (line 29)
background:#FFFFFF url(../images/jaques/jaques_colour_image2.jpg) no-repeat scroll 98% 50%;
}
 
.Three #header {charouxstyle.css (line 29)
background:#FFFFFF url(../images/jaques/jaques_colour_imagee.jpg) no-repeat scroll 98% 50%;
}

etc etc etc.....

Many thanks,
Liam
www.liamsmart.co.uk

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 5 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

^similar to the id="index"

^similar to the id="index" on the body-- does the same thing. : )

Looking very nice.

I'm no expert, but I fake one on teh Internets

Deuce
Deuce's picture
Offline
Guru
Somewhere, USA
Last seen: 4 years 20 weeks ago
Somewhere, USA
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4424
Points: 1843

ya, i tend to stick with

ya, i tend to stick with giving the an id="index" or id="portfolio" etc...

all ยป http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

liam.smart
Offline
Enthusiast
Dundee, Scotland
Last seen: 12 years 34 weeks ago
Dundee, Scotland
Joined: 2008-06-26
Posts: 164
Points: 0

putting classes or id's on

putting classes or id's on the body tags is frowned upon where i work ehnce me saying the header or wrapper.

I put classes on the body tags of my own website, but sitting in work so force of habbit.

Six of one, half a dozen of the other as my old man would say.... Laughing out loud

Many thanks,
Liam
www.liamsmart.co.uk

wolfcry911
wolfcry911's picture
Offline
Guru
MA, USA
Last seen: 7 years 39 weeks ago
MA, USA
Timezone: GMT-5
Joined: 2004-09-01
Posts: 3224
Points: 237

liam.smart wrote:putting

liam.smart wrote:

putting classes or id's on the body tags is frowned upon where i work

May I ask why? It's such a powerful and useful practice.

liam.smart
Offline
Enthusiast
Dundee, Scotland
Last seen: 12 years 34 weeks ago
Dundee, Scotland
Joined: 2008-06-26
Posts: 164
Points: 0

I dont know mate. Just a

I dont know mate. Just a taste thing I guess. I dont ask questions, I just get on with the work :shrug:

Like I said, Ive always done it on website to keep a menu state active etc.

Many thanks,
Liam
www.liamsmart.co.uk

needy
Offline
Enthusiast
australia
Last seen: 12 years 43 weeks ago
australia
Timezone: GMT-1
Joined: 2007-06-11
Posts: 95
Points: 0

Quote:putting classes or

Quote:

putting classes or id's on the body tags...

So which is better - class or id? Is there a rule to this?

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 5 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

Not really. As Liam shows,

Not really. As Liam shows, some people just prefer classes (though I think his problem is more with setting things on teh body tag at all rather than on a container). I actually just got kinda reamed by a Perl writer who didn't like that I set all my ul's to list-style: none (as the majority of my lists are menus and never have bullets) and would rather that every ul have a class on it to remove bullets so the one list I have that DOES have bullets is the default.

I don't like that because I don't like adding classes to everything, it feels ugly to me. However, there's nothing wrong with doing it like that and it's purely a taste thing (my taste is, fewer names of any kind is better). Every *whatever here* doesn't need a name, just the one that's special. Keep the majority using a set default as much as possible, as this reduces code. (I'm thinking of a Monty Python song and a George Carlin routine another Crusty I know likes to quote here.)

In general, the rule of thumb for id's versus classes is, if there's one of it, it gets an id, and if there are more of them, they get a class.

Like, a list:

I had something similar (even with the bad class name, border) for a sidebar menu that, for whatever reason, needed seemingly random borders on stuff. So there were more than one list item who needed to hold the border.
I used a class because there were several list items and also several special list items. The ul, however, is the only one of its kind (with its styles etc) and so it got an id (also poorly named, note). If I'd had several menus who were kinda styled the same way, it would be a class instead of an id.

You can have both as well, just don't try to refer to both of them at the same time:

I'm no expert, but I fake one on teh Internets

liam.smart
Offline
Enthusiast
Dundee, Scotland
Last seen: 12 years 34 weeks ago
Dundee, Scotland
Joined: 2008-06-26
Posts: 164
Points: 0

Im not saying class or id is

Im not saying class or id is better. Its just anything on the body is liked here. It just has to stay plain old .

I would have thought adding a class to the container would be better than an ID. Your page wont validate if you have the same ID twice. So to stick aid of 'home' on the body, and then say you use it on the menu tab that is the home link, the page wont validate. Where as a class can be used as many times as you want.

But thats just what I use. there is nothing wrong with using an ID.

Many thanks,
Liam
www.liamsmart.co.uk

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 6 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Quote:I actually just got

Quote:

I actually just got kinda reamed by a Perl writer who didn't like that I set all my ul's to list-style: none (as the majority of my lists are menus and never have bullets) and would rather that every ul have a class on it to remove bullets so the one list I have that DOES have bullets is the default.

Sadly you all sound as though you are at the mercy of backend scripters, poking their noses in where they don't belong Smile it was said once before you are the frontend coders what happens with markup is your concern alone, class tokens or ID's they are your concern stop letting people dictate your job to you. If a token is required for scripting I ok where it goes or even if that is the best approach, on all matters markup The final decision rests with me that doesn't mean that others can't dabble it just means that the frontend coder is responsible for the final cut and is the one sitting in the middle as the pivotal point in the development process.

So step up to the plate, argue your position don't let others tell you that a body or html tag mustn't contain tokens or identifiers , that's simply piffle! Smile yes yes I know, powers that be etc :mad:

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 5 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

'sok Hugo, he's not working

'sok Hugo, he's not working on any of my stuff. Hubby's working the back end on that page (though he strongly disagrees with you, lawlz) and he likes cleaner HTML. But for instance in Perl you avoid setting global changes like that, as it's a headache for the next guy who'd got to step in and maintain that. But I feel that anyone claiming to know CSS should be able to catch that
ul {
list-style: none;
}
at the top of my CSS page, and is perfectly able to add display: list-item to the single list s/he wants bullets added to.

But then again, I feel this other guy's view is why so many with programming backgrounds add classes to everything. It's what you should be doing on the backend, and it's no load on anything if those classes are never called-- unlike in CSS where the whole huge HTML and CSS are loaded by the user, even if the CSS isn't referring to anything in the HTML page.

Quote:

I would have thought adding a class to the container would be better than an ID. Your page wont validate if you have the same ID twice. So to stick aid of 'home' on the body, and then say you use it on the menu tab that is the home link, the page wont validate. Where as a class can be used as many times as you want.

In my case if I were to stick something like a universal name on a container, it would indeed have to be a class as the div already has an id of "container" usually.
You bring up a good point, if people have id's on their menu items (for image replacement for instance) and then think, hey this is the Home page and try #home on the body, sure, that's a problem. I call the main page "index" on my body id's and the rest get a name kinda describing the page better.

I've used classes on the body when I had a bunch of form pages which were completely different from pages which had no forms. I could've stuck them on the containers, but just didn't.

Unfortunately when the back-enders stick my code into their templates, there's often an ugly
sittin there. But by then I've wiped my hands of it and refuse to allow my name be associated with the code at that point, as always. Templates are written in codez (PHP, Perl) and they are not something I can deal with.

I'm no expert, but I fake one on teh Internets

needy
Offline
Enthusiast
australia
Last seen: 12 years 43 weeks ago
australia
Timezone: GMT-1
Joined: 2007-06-11
Posts: 95
Points: 0

Well i removed the 5

Well i removed the 5 different! style sheets I'd used initially to have a different image in the header on the 5 decade pages and added IDs to the body tags in the html. I had to search a bit to find out that I could modify the body tag in the pages that were linked to DW templates and therefore not editable).link to how to
I used y1980, y1990 etc as Stomme Poes suggested - worked brilliantly and was able to affect the remaining pages via the index id on the homepage.
cheers all.

CupidsToejam
CupidsToejam's picture
Offline
Guru
Florida
Last seen: 6 years 12 weeks ago
Florida
Timezone: GMT-4
Joined: 2008-08-15
Posts: 2637
Points: 1556

I think you guys are

I think you guys are forgetting a major difference in ID's vs Classes. ID's hold more specificity then classes.

ID = 1,0,0
class = 0,1,0

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 5 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

nuh-uh! : )

"Stomme poes" wrote:

both legal, both refer to the header (though the id has more "weight" if an id and a class conflict).

: )

Though for something like the body or the main page wrapper, you're less likely to conflict than in the rest of the page.

I'm no expert, but I fake one on teh Internets