This is a discussion on "[SOLVED] How do the symbols * . and # apply to IDs differently?" within the Web Page Design section. This forum, and the thread "[SOLVED] How do the symbols * . and # apply to IDs differently? are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] How do the symbols * . and # apply to IDs differently?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
[SOLVED] How do the symbols * . and # apply to IDs differently?
So I've been doing some site reading and have been plowing through source CSS to see how 'other people' do it to get a grip on how CSS can be applied and what magic it makes happen.
There is one thing I'm a bit unsure about though. Reading through, I've often seen the symbols *, . or # applied in front of an ID or applied at least somewhere in the first line. At first I thought that # was instead of 'div ID' to make things shorter and tidier but now I'm not sure. Would someone be able to explain to me how the symbols are used in CSS and how their application differentiates from the others? i.e using * instead of # and so on. I'd be hugely grateful |
|
|
|
#2
|
||||
|
||||
|
Re: How do the symbols * . and # apply to IDs differently?
# in css indicates an ID. Say if in your html you have
I guess I should also mention that . is for assigning style to a class (much like an ID, but can have multiple instances in the same page) So for
The only items in css that don't require the # or . or when you apply styles to html tags (body, div, a ,span etc). Going back to the first example, 'div#menu' is effectively the same as using '#menu', the same as 'a.link is the same as '.link'. It's sometimes useful however to use the former, as you can tell straight off what tag you used that particular id or class on
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Last edited by Aso; Nov 9th, 2007 at 16:31. |
|
#3
|
|||
|
|||
|
Re: How do the symbols * . and # apply to IDs differently?
Alright ... well ...
# is the symbol for ID selector ... so ... your ID CSS
CSS
* is the universal selector using this mean to apply the properties to ALL elements. Read this article - No Margin For Error |
|
#4
|
||||
|
||||
|
Re: How do the symbols * . and # apply to IDs differently?
In the css you you will have '*','#' and '.'.
Firstly the * is for a universal selector, if you use this, this will apply to ALL. # is for an id=. You can use it like: CSS:
.'s (dots) are for class=. You can use it like: CSS:
You can also use "BODY, HTML, p, etc" in your css. Like so:
I will try and find a website that will explain this better EDIT: Just noticed Karinne's post! Check out her links - especailly the No Margin For Error...
__________________
Marc Staff Manager - Webforumz.com Want to be a moderator? PM me. Last edited by Marc; Nov 9th, 2007 at 16:29. Reason: Missed a bit! |
|
#5
|
|||
|
|||
|
Re: How do the symbols * . and # apply to IDs differently?
"*" is the universal selector. It matches any element. For example:
"." denotes a class. For example:
"#" denotes an ID. These are much the same as classes, but IDs must be unique; only one element can ever have an id (such as <div id="header">). IDs are more convenient to manipulate with javascript than classes are, and they also "rank" much higher than classes whenever there is a conflict of CSS rules.
|
|
#6
|
||||
|
||||
|
Re: How do the symbols * . and # apply to IDs differently?
LOL 3 people replyed with *nearly* the same thing
__________________
Marc Staff Manager - Webforumz.com Want to be a moderator? PM me. |
|
#7
|
||||
|
||||
|
Re: How do the symbols * . and # apply to IDs differently?
lol, enough info for you
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
|
|
#8
|
|||
|
|||
|
Re: How do the symbols * . and # apply to IDs differently?
Ahhhh, I see! That makes a lot of sense! Thanks everyone!
|
|
#9
|
|||
|
|||
|
Re: [SOLVED] How do the symbols * . and # apply to IDs differently?
I wish to add my example but, I'm afraid someone will delete my thread for clearing up... lol
All the example given above is very cristal clear..
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Symbols in CSS | pallworthy | Web Page Design | 4 | Apr 17th, 2008 20:34 |
| using “”-_()&,\ Symbols | wireman54301 | Hosting & Domains | 0 | Apr 18th, 2006 06:01 |
| designed a website in CSS but displays differently in other browsers | skyfire400 | Web Page Design | 8 | Jan 25th, 2006 11:53 |
| Fonts display differently in FF and IE | Chico | Web Page Design | 4 | Jan 2nd, 2006 12:52 |
| Simple HTML displayed differently between browsers | RichRadio2005 | Web Page Design | 0 | Nov 29th, 2005 14:04 |