...

View Full Version : attribute selector aka [att=val] css



Tythsai
01-02-2006, 11:37 PM
ive been straining my brain for the past 6 hours trying variation after variation of this code.

i even broke it down as simple as i could get it, taking the parts onto a new page and trying just the one css line, and the one element tree.

no matter how i try to work on this, the only way anything happens is if i take out the [width] component of the selector.


<html>

<head>

<title>New Page 1</title>
<style type="text/css">
table{ background-color: red }
</style>
</head>

<body>
<table width=800>hi </Table> <table width=700> hi2 </table>
</body>

</html>


this produces 2 red tables, of two diffrent widths, both with text inside.


<html>

<head>

<title>New Page 1</title>
<style type="text/css">
table[width]{ background-color: red }
</style>
</head>

<body>
<table width=800>hi </Table> <table width=700> hi2 </table>
</body>

</html>


this produces the word hi2 under the word hi, both on the left end of the screen.

i am extremely confused. w3.org gives examples of how to use this, and i obviously am having trouble.

i already checked that nothing was wrong with my version of frontpage. i copied the desired code into notepad, attempted it at someone elses house. im just lost.

can someone please explain the correct format?

cronic5
01-03-2006, 06:21 AM
You never said what you'tr trying to do. What is it exactly you are trying to do? The only thing I would think you are trying to do is get the content inside the tables. If so, you need a table row as well as a table data tag. The [width] part confuses me because there is no reason to have that. Here is what I am guessing you're trying to do:



<html>

<head>

<title>New Page 1</title>
<style type="text/css">
table
{
background-color: red
}
</style>
</head>

<body>
<table width="800">
<tr>
<td>
hi
</tr>
</td>
</table>

<table width="700">
<tr>
<td>
hi2
</tr>
</td>
</table>

</body>
</html>

_Aerospace_Eng_
01-03-2006, 08:13 AM
It looks like you are trying to find all tables that have the width attribute but in order for this to work you need to give it a value as well but honestly I wouldn't even bother with this yet. IE6 currently doesn't support what you are trying to do.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum