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.

Id's and Classes

Featured Replies

Something has really annoyed me recently.

 

My experience of id's and classes have always been, if you use more than one, its a class, if its unique, you use an id.

 

Recently I had to integrate my html/css into a .net backend and I had to change 99% of my id's to classes because of the way .net selects them ( i am told).

 

Is there any other reason to distinguish between id and classes so I dont get caught out again? Whats your working practice?

 

Steve

You can use multiple classes at once, so generally classes win for me. Although id's always win on the whole specificity thing. Generally i think the biggest thing about id's an classes is the semantic information they carry, when you see id="nav" it tells you what it contains and that there is only one on the page, whereas class="box" tells you if you go fiddling with it, other elements will be affected.

 

Although you can always use someing like <div class="box small left" to break the styles down, so box defines it's a box, small defines the sizes and then left defines the float.

 

Anyway ramble, it sucks if you can't use classes, the reason above is the best part about them, the ability to use multiiple classes means you can break them down into some simple commands, so defining like 6 classes, allows you to make dozens of combinations.

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.