Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

A noobie question about css...

Featured Replies

Hey so I've got a question I think I should know but don't know.

 

For example sometimes I see things like this:

.header {

background-color: #000000;

{

And some like this:

#header {

background-color: #000000;

}

Notice the "." and the "#"

 

 

What is the difference if you denote it with a period or ampersand?

 

 

Thanks,

Meshach

The period/full stop selects by class, the hash (not ampersand) selects by id.

 

For example:

 

#header {
background-color: #000000;
}
.headertext {
color: #ffffff;
}

 

<div id="header">
<p class="headertext">Sometext</p>
</div>

A completely unsemantic example, however you can see the div has an id, and the p has a class, and which selector corresponds to which.

 

id's are usually used for structural sections/elements like header etc, where as classes are used to differentiate between different styles within those sections, or styles which appear in more than one section.

 

P.S. Hex color values must also be proceeded by a hash "#" so it should be:

#header {

background-color: #000000;

}

P.S. Hex color values must also be proceeded by a hash "#"

 

And if you're on a Macbook (with no hash key) - use Alt + 3. There's probably an easier way that I haven't discovered though.

Mac's don't have a # key?

 

I thought they were meant to be good!

  • Author
The period/full stop selects by class, the hash (not ampersand) selects by id.

 

For example:

 

#header {
background-color: #000000;
}
.headertext {
color: #ffffff;
}

 

<div id="header">
<p class="headertext">Sometext</p>
</div>

A completely unsemantic example, however you can see the div has an id, and the p has a class, and which selector corresponds to which.

 

id's are usually used for structural sections/elements like header etc, where as classes are used to differentiate between different styles within those sections, or styles which appear in more than one section.

 

P.S. Hex color values must also be proceeded by a hash "#" so it should be:

#header {

background-color: #000000;

}

 

Okay. Thank you, I think I understand now. . . :D

 

 

And if you're on a Macbook (with no hash key) - use Alt + 3. There's probably an easier way that I haven't discovered though.

 

I'm using a windows, I mistakingly left out the hash... Sorry. :blush1:

Mac's don't have a # key?

 

I thought they were meant to be good!

 

Not on my Macbook Pro (laptop) because it's a condensed keyboard. It might also be a UK thing, because we don't use the # to indicate a number.

 

On the current USB keyboards they do.

My Mac Book doesn't have a '#' either. As you said it's probably because it's a condensed keyboard.

Whether you have a hash key or not probably depends on the country you are in as American and English keyboards vary.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.