Images with CSS

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Images with CSS

Post by Archy »

Is there a way to define images with CSS, such as set the borders of all images to 0 etc? Any help would be nice.

Thanks.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Yes, there is :)

Code: Select all

img {
  border: none;
  /* other style rules here */
}
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post by Archy »

Ofc, how stupid of me :\

Is there a way to get the alt tags in that as well, I tried...

Code: Select all

img {
  border: none;
  alt: text here;
}
... but it did not work. Any ideas, or will I have to enter all of them all into the picture manually (Sigh).

Thanks.
zenabi
Forum Commoner
Posts: 84
Joined: Mon Sep 08, 2003 5:26 am
Location: UK

Post by zenabi »

CSS doesn't work like that I'm afraid, you'll have to enter the "alt text" in your HTML code.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

The whole point of css is to seperate content from presentation (data vs. how the data is displayed). The alt attribute is meant to describe the picture which is being displayed, therefor it's data and has no place in css.

If are intent on giving all images the same description you can use php. But this defeats the purpose of the element and why it's required in order for a page to be valid xhtml.
User avatar
no_memories
Forum Contributor
Posts: 145
Joined: Sun Feb 01, 2004 7:12 pm
Location: New York City

Post by no_memories »

Each new version of (x)html deprecates more of the hhml attributes than the previous version relying more and more on css to layout or presentation.


Basically xhtml is html housing of text in an xml fashion and then styled using css. common tags in html 4.01 like align and height will no longer be valid in say xhtml 1.1 within most html elements. Now that xhtml 2.0 is on the horizon, xhtml proves to be even more modular and reliant on css and other forms of presentation to display the site.

Let's hope the browsers start nailing down css the way it should be, fully supporting the 2.1 standards, and working very hard to support the 3.0 standards. But Microsoft is hell bent on holding back the Internet with I.E. 6 by not upgrading or improving the browser.
Post Reply