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.

I'm messing things up with my CSS, what I'm doing wrong?

Featured Replies

Hi

 

Many times I have this problem.

 

I have all my common CSS styling codes in a separate file, and all my website's files link to it by adding

<link rel="stylesheet" type="text/css" href="webstyle.css">

in the head section.

My styling contains my background color, font color, etc.

 

So that's fine. All pages display as they should.

 

However, when I need to make a specific page somewhat different, I don't know how I should add CSS. What I usually do is just add the same code I mentioned above in the head's section and then add my extra CSS in the page I want to modify. To add the CSS for example I might say

<style type="text/css">
body
{
background-color:black;
}
</style>

 

Sometimes this works but sometimes not. Specifically the example I gave here with the black bg color doesn't work. Why?

I'm I doing it the right way?

Also think I'm doing something wrong, as many times my CSS styles are confused, for example, a page may be reading CSS styles from another page, even if I didn't tell it to read CSS from there.

 

Thanks in advance.

My advice would be stick to your styles on a separate file; you can always create a second file and refer to it as you did the first. The idea is then you can edit your css easily without touching the html.

 

Saves you a lot of time and bother. If you have css in your html and separate it begins to confuse as to where problems may stem from .

 

HTML dog has some great info to help you get up and running... starting here if you like : http://www.htmldog.com/guides/cssbeginner/applyingcss/

 

Hope this helps :D

  • Author

Thanks.

 

What you are saying is that I should avoid putting CSS styles in my HTML files, and just put all my CSS styles in one or more CSS files?

 

I'll try it now, thanks it sounds more tidy anyway.

Yes that's what I'm saying. In some cases I believe inline (in HTML) styling is appropriate, but this is in relation to other languages and not in most html / css coded sites.

 

It just makes for really hard work when you come to (and you will) edit and play around with code to get things to behave as they should in all browsers! :rolleyes:

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.