Basic question about styles

Dell DELL
February 13, 2009 at 13:06:45
Specs: Vista, P4
I'm trying to set a style to use within a DIV tag. This doesn't work. What am I doing wrong?

boxstyle1 {
border-style:solid;
border-color:#FFCC66;
border-width:thin;
background-color:#FFCC66;
}

<div style="boxstyle1">Blah blah blah</div>


See More: Basic question about styles

Report •


#1
February 13, 2009 at 13:21:03
Put a period (.) or pound sign (#) before the definition of boxstyle1:

.boxstyle1 {
border-style:solid;
border-color:#FFCC66;
border-width:thin;
background-color:#FFCC66;
}

Then in the div tag, use either the "class" or "id" attribute:

<div class="boxstyle1">Blah blah blah</div>

In the style definition, a period is used for class attributes; a pound sign is used for id attributes.


Brad


Report •

#2
February 13, 2009 at 17:45:43
As a side note, you may encounter inconsistencies using "thin" for the width. For example, IE6 and Firefox have different ideas on what "thin" is.

A shorthand notation can also be used within class, id, and/or style.

<div style="border: 1px solid #ffcc66">stuff</div>

HTH


Report •

Related Solutions


Ask Question