Connecting Tech Pros Worldwide Forums | Help | Site Map

css syntax

sam
Guest
 
Posts: n/a
#1: Feb 10 '06
Hi,

Does anyone know why there is a hash (#) in front of each css style?
please see the following example:

<style type="text/css">
#leftcolumn{
float:left;
width:150px;
height: 400px;
border: 3px solid black;
padding: 5px;
padding-left: 8px;

}

#leftcolumn a{
padding: 3px 1px;
display: block;
width: 100%;
text-decoration: none;
font-weight: bold;
border-bottom: 1px solid gray;
}

#leftcolumn a:hover{
background-color: #FFFF80;
}

#rightcolumn{
float:left;
width:550px;
min-height: 400px;
border: 3px solid black;
margin-left: 10px;
padding: 5px;
padding-bottom: 8px;
}

* html #rightcolumn{ /*IE only style*/
height: 400px;
}
</style>

It should be without hash, I usually use the following css syntax:

body{ background-color: black }
p { color: blue; }
h3{ color: white; }


Thanks
Sam

Harlan Messinger
Guest
 
Posts: n/a
#2: Feb 10 '06

re: css syntax


sam wrote:[color=blue]
> Hi,
>
> Does anyone know why there is a hash (#) in front of each css style?
> please see the following example:[/color]

That's how you indicate a match on an element's ID attribute.
[color=blue]
> <style type="text/css">
> #leftcolumn{
> float:left;
> width:150px;
> height: 400px;
> border: 3px solid black;
> padding: 5px;
> padding-left: 8px;
> }[/color]

[snip]
[color=blue]
> It should be without hash,[/color]

No, it shouldn't be. (Besides, if you already knew that it should be,
then why didn't you just delete the hash instead of asking why it's there?)

I usually use the following css syntax:[color=blue]
>
> body{ background-color: black }
> p { color: blue; }
> h3{ color: white; }[/color]

These apply, respectively, to <body>, <p>, and <h3> elements in an HTML
document. The styles you listed are meant to match elements with
id="leftcolumn" or id="rightcolumn". (There are no <leftcolumn> or
<rightcolumn> elements.) Similarly, names preceded by a period are meant
to match elements whose class attributes include those names.
Closed Thread