473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Accessing An Image From .css

Sorry, but I have tons of questions tonight, but I will post them one by
one.

Using i.e. 6+ and NS 7+

How do you set properties for a pictures from a style sheet?

For example:

<img name="Picture"></img>

<style>
img ??? {
width: 400px;
}
</style>

Is that possible? I have tried all the variations I could think of
img.Picture, #Picture img, img.#Picture, I know you can set properties
for all images by using img {}, but that is as far as I can get. Any
help is appreciated.

Jul 20 '05 #1
3 6824
Heath <hj******@email.moc> wrote:
Is that possible? I have tried all the variations I could think of
img.Picture, #Picture img, img.#Picture, I know you can set properties
for all images by using img {}, but that is as far as I can get. Any
help is appreciated.


Are you trying to set properties for just that one picture? If so, try this:

<img id="mypicture" src="pic.png" alt="a picture of me" width="400"
height="400">

Note the alt attribute for alternate text and the id attribute which will
help identify the element in the CSS. Now, for the style, use:

#mypicture
{
/* various propeties */
}
--
Michael Wilcox
mjwilco at yahoo dot com
Essential Tools for the Web Developer - http://mikewilcox.t35.com
Jul 20 '05 #2
Heath wrote:
Sorry, but I have tons of questions tonight, but I will post them one by
one.

Using i.e. 6+ and NS 7+

How do you set properties for a pictures from a style sheet?

For example:

<img name="Picture"></img>
The closing tag for <img> elements is forbidden. In HTML, just omit it. In
XHTML, use the empty element syntax:

<img src="..." alt="..." />

<style>
img ??? {
width: 400px;
}
</style>

Is that possible? I have tried all the variations I could think of
img.Picture, #Picture img, img.#Picture, I know you can set properties
for all images by using img {}, but that is as far as I can get. Any
help is appreciated.


If you mean how do you select one particular image, in CSS 2 conforming
browsers, you can simply use an attribute selector:

<img src="foo.png" alt="..." />

img[src=foo.png] {
/* Whatever you want here. */
}

However, Internet Explorer is broken and has a large market share, so you'll
have to use an id:

<img src="..." alt="..." id="bar" />

img#bar {
/* Whatever you want here. */
}

Alternatively, if you want to select a group of images, a class would be
more appropriate:

<img src="..." alt="..." class="baz" />

img.baz {
/* Whatever you want here. */
}

Consult any CSS tutorial for information on how you can select elements in
different ways, or better yet, consult the definitive source, the CSS 2
specification:

<URL:http://www.w3.org/TR/REC-CSS2/selector.html>
--
Jim Dabell

Jul 20 '05 #3
In article Heath wrote:
Sorry, but I have tons of questions tonight, but I will post them one by
one.

Using i.e. 6+ and NS 7+ How do you set properties for a pictures from a style sheet?

For example: <img name="Picture"></img>

<style> img[name="Picture"] { width: 400px;
}
</style>
Attribute selector don't work on IE.
Is that possible? I have tried all the variations I could think of
img.Picture, #Picture img, img.#Picture,


None of them is good. first would work if you had class="Picture" on your
image tag, second would work if you had wrapped your image in element
with id="Picture" and last wouldn't work at all.

Use id attribute instead name.

<img id="Picture">

<style>
#Picture { width: 400px;}
</style>

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mir nazim | last post by:
hi, i m facing a problem in properly accesing BLOBs from mysql db. when i display an image stored in the blob field it show some absurd characters. i think it is the problem of properly telling...
6
by: Rob Meade | last post by:
Hi all, I went on an XML course over a year ago and have finally got around to having a use for it, but do you think I can actually remember anything - nope!.. Ok, here's what I want to do -...
8
by: Jeronimo Bertran | last post by:
I have an aspx page that saves some information using the ViewState. This page has an IMG META that uses a second aspx page to render the image. <IMG src= "ImageRender.aspx"> I noticed that...
2
by: R Duke | last post by:
I have tried everything I can think of to change the visible property of a design time created control from a dynamically created control's command event handler. Here is the scenario. I have...
2
by: DOM_scripter | last post by:
Hi, I want to set a picture on the fly. For this I have a html file with only an <img> tag - kind of a placholder. So I do myWindow=window.open("data/myFile.html"). Then I set the src attribute of...
7
by: simchajoy2000 | last post by:
Hi, I am just a javascript beginner so maybe this is a simple problem but I am trying to do some rollovers on images in a separate <div>. Here is the relevent piece of my code: <html>...
2
by: onerobe | last post by:
Hi everyone. I have this bizarre problem and i am hoping someone can point me in the right direction. I have a group of form selects, and when one is changed it dynamically changes the content...
0
by: Luke | last post by:
I have a big (500+ MB) multipage TIFF image file and a database file which contains index to each image in the TIFF file. The scheme of the database is very simple. imagename (text) byte...
0
by: Luke | last post by:
I have a big (500+ MB) multipage TIFF image file and a database file which contains index to each image in the TIFF file. The scheme of the database is very simple. imagename (text) byte...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.