advice on images and CSS

W

Wombatwal

G'day all
I am putting together a family history web site. I have a few pages with a
number of images on each. The images are different dimensions, some are
portrait and others landscape.
To lay them out with a style should I use in line style sheet or go for a
external style sheet.
I ask this because each image will be styled individually because of their
differences.
Thanks
 
A

Andy Dingley

Wombatwal said:
To lay them out with a style should I use in line style sheet or go for a
external style sheet.

External, with a style attribute on each <img>/<div> around it. Put
everything you can in the external stylesheet (including a reasonable
default size), sizes and put any varying part into the attributes.

For anything with common groups ("relatives in Australia", "the black
sheep we don't talk about") then use relevant classes and styles in the
stylesheet. Remember that you can apply multiple classes to the same
element (space-separated in the same class attribute)

The alternative is a vast number of #id values linking everything
together. Although we have a general rule that "stylesheets are better
practice than style attributes", it breaks down in this case. Where the
scope of a style rule really is this narrow (and is going to stay that
way) then there's no problem in sticking it directly onto the HTML.

If you have more than two, maybe three style rules in one of these
style attributes, then there's something wrong. In particular you
shouldn't need to set the size of both nested elements (such as an
<img> and a <div> for a border).
 
R

richard

Wombatwal said:
G'day all
I am putting together a family history web site. I have a few pages with a
number of images on each. The images are different dimensions, some are
portrait and others landscape.
To lay them out with a style should I use in line style sheet or go for a
external style sheet.
I ask this because each image will be styled individually because of their
differences.
Thanks

To do something of that nature, I would take the time to resize like images
to be the same dimensions.
Don't rely on the coding to resize them for you.
Such as all landscapes being like 400x320.
Even portraits would have at least a height of 400, then leaving the width
to be determined by the image itself.
Irfanview has a good batch program to do resizing fairly simply.
www.irfanview.com
 
M

mbstevens

To lay them out with a style should I use in line style sheet or go for a
external style sheet.

External style sheets are usually best. Height and width can be in the
markup, though. This *may* mean that you don't really need a different
style for each image.
I ask this because each image will be styled individually because of their
differences.

If you _really_ do need different styles, make up some image classes, one
of which will fit any image in the site. If that is not enough, then
in-line styles may be required, but it is hard for me to imagine a site
that would _really_ need this.
 
W

Wombatwal

Thanks all.
Bruce

mbstevens said:
External style sheets are usually best. Height and width can be in the
markup, though. This *may* mean that you don't really need a different
style for each image.


If you _really_ do need different styles, make up some image classes, one
of which will fit any image in the site. If that is not enough, then
in-line styles may be required, but it is hard for me to imagine a site
that would _really_ need this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top