| Author |
CSS dummy needs help
|
|
|
|
In a css file such as the one below
Why would one entry start with a # and others a . ??
Thanks
----------------------------
#right{
background-color: #505096;
border: solid #505096 1px;
width: 120px;
float: right;
color: #FFFFFF;
}
#footer{
margin: 5px;
background-color: #FFFFFF;
border: solid #505096 1px;
clear: both;
}
..title{
font: bold 1.8em Arial;
}
..subtitle{
font: bold 1.3em Arial;
}
| |
| David Blomstrom 2005-12-29, 3:15 am |
| P.F. wrote:
> In a css file such as the one below
>
> Why would one entry start with a # and others a . ??
>
> Thanks
>
> ----------------------------
>
> #right{
> background-color: #505096;
> border: solid #505096 1px;
> width: 120px;
> float: right;
> color: #FFFFFF;
> }
>
> #footer{
> margin: 5px;
> background-color: #FFFFFF;
> border: solid #505096 1px;
> clear: both;
> }
>
> .title{
> font: bold 1.8em Arial;
> }
>
> .subtitle{
> font: bold 1.3em Arial;
> }
>
>
# denotes an id, . a class.
You can use an id just once per page. For example:
<p id="pfirst">
....matched to this on your style sheet:
#pfirst { text-indent: 0px; }
But you can use several classes per page:
<td class="left"></td>
<td class="left"></td>
Your style sheet might then say this:
td.class { text-align: left; }
You can also combine id's and classes:
<td class="nation" id="usa"></td>
<td class="nation" id="mex"></td>
| |
|
| Thanks DB .. great info to keep moving with.
I am sure I will be back.
"David Blomstrom" <david_blomstrom@yahoo.com> wrote in message
news:43B3547F.3000804@yahoo.com...
> P.F. wrote:
>
> # denotes an id, . a class.
>
> You can use an id just once per page. For example:
>
> <p id="pfirst">
>
> ...matched to this on your style sheet:
>
> #pfirst { text-indent: 0px; }
>
> But you can use several classes per page:
>
> <td class="left"></td>
> <td class="left"></td>
>
> Your style sheet might then say this:
>
> td.class { text-align: left; }
>
> You can also combine id's and classes:
>
> <td class="nation" id="usa"></td>
> <td class="nation" id="mex"></td>
>
>
| |
| Scott Powell 2005-12-29, 3:20 am |
|
"David Blomstrom" <david_blomstrom@yahoo.com> wrote in message
news:43B3547F.3000804@yahoo.com...
> P.F. wrote:
>
> # denotes an id, . a class.
>
> You can use an id just once per page. For example:
>
> <p id="pfirst">
>
> ...matched to this on your style sheet:
>
> #pfirst { text-indent: 0px; }
>
> But you can use several classes per page:
>
> <td class="left"></td>
> <td class="left"></td>
>
> Your style sheet might then say this:
>
> td.class { text-align: left; }
>
> You can also combine id's and classes:
>
> <td class="nation" id="usa"></td>
> <td class="nation" id="mex"></td>
Because ID's are used only once per page, you can use dynamic html to
manipulate that element with a unique Id name. You can single it out, and
tell it what to do using DHTML.
Scott Powell
Web Developer
http://www.glweb.biz
| |
|
| For anyone who cares ...
http://www.tizag.com/cssT/cssid.php
"David Blomstrom" <david_blomstrom@yahoo.com> wrote in message
news:43B3547F.3000804@yahoo.com...
> P.F. wrote:
>
> # denotes an id, . a class.
>
> You can use an id just once per page. For example:
>
> <p id="pfirst">
>
> ...matched to this on your style sheet:
>
> #pfirst { text-indent: 0px; }
>
> But you can use several classes per page:
>
> <td class="left"></td>
> <td class="left"></td>
>
> Your style sheet might then say this:
>
> td.class { text-align: left; }
>
> You can also combine id's and classes:
>
> <td class="nation" id="usa"></td>
> <td class="nation" id="mex"></td>
>
>
| |
| Michael Fesser 2005-12-29, 10:21 pm |
| ..oO(P.F.)
>For anyone who cares ...
>
>http://www.tizag.com/cssT/cssid.php
Incomplete and not entirely correct:
| Notice that an ID's CSS is an HTML element, followeb by a "#", and
| finally ID's name - "element#idname".
While many people prefer such a notation, it's not always necessary.
"#idname" works the same (except for a slightly smaller specificity).
| Use IDs when there is only one occurence per page. Use classes when
| there are one or more occurences per page.
That's rather nonsenese and doesn't mention the important things. Of
course you can also use a class even if it's just used once on a page.
But there's something more to say about IDs:
* greater specificity than anything else
* can be used as named anchors
* can be used in client-side scripting (DOM): document.getElementById()
* usually used to denote some logical main parts of a page, e.g.
navigation and content areas
Micha
| |
| mzanime.com 2005-12-29, 10:21 pm |
| Thanks for pointing out those important truths Micha, there is nothing I dislike more than half-assed tutorials :-)
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |