0

Class and id selector won't work in an external CSS file

i'm trying to use Class or id selectors in an external CSS file which i linked to my html page via Visual Studio however, i can't figure out why id or class not work if i use them in an external CSS file for example here's my HTML Paragraph: <p class="About"> AFX Group offers trading and investment services in multiple languages throughout the world. We allow investors to access a range of markets and trade various financial instruments, including forex, indices, equities, bonds, and commodities. Moreover, we offer cutting-edge trading platforms, comprehensive trading tools, advanced educational resources, the latest financial news and much more. </p> and here's what i placed in my external CSS file .About { background-color:white; } the only thing works in my html page which i linked to external CSS link is these lines which i placed in body body { background-image: url("http://www.afxgroup.com/template/AFX/img/header/about-image.jpg"); background-color: #cccccc; background-repeat: no-repeat; background-attachment: fixed; background-position: center; } so how can i make Class or ID selector work with my external CSS file which i linked to my html About page thanks alot

14th Nov 2017, 8:30 AM
Omid Navid
Omid Navid - avatar
5 Respostas
+ 17
@Omid make sure your HTML, CSS (include JS if its used) are in the same folders. specify correct file names. your code posted in comments works when i changed the id selector to about it was selector before which did not exist.
14th Nov 2017, 9:49 AM
Lord Krishna
Lord Krishna - avatar
+ 1
Can you share the whole HTML, in order to see the problem.
14th Nov 2017, 8:39 AM
eRosz
eRosz - avatar
+ 1
the problem is that, how can i make class or id selector work in a stylesheet which linked to an HTML File ok let me see, this is the html file code which for now contains a background, and a paragraph: <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>About Us</title> <link rel="stylesheet" href="About.css" /> </head> <body> <h1 align="center">About The Company</h1> <hr width="50%" align="center" /> <div id="About"> <p> AFX Group offers trading and investment services in multiple languages throughout the world. We allow investors to access a range of markets and trade various financial instruments, including forex, indices, equities, bonds, and commodities. Moreover, we offer cutting-edge trading platforms, comprehensive trading tools, advanced educational resources, the latest financial news and much more. </p> </div> and here is the stylesheet which i linked to the html the stylesheet's name is About.css body { background-image: url("http://www.afxgroup.com/template/AFX/img/header/about-image.jpg"); background-color: #cccccc; background-repeat: no-repeat; background-attachment: fixed; background-position: center; } #selector { background-color:white; } the matter is it don't apply the white background on the paragraph why ?
14th Nov 2017, 9:11 AM
Omid Navid
Omid Navid - avatar
+ 1
Probably because there's nothing with the ID 'selector'? Try this: #About { background-color:white; }
14th Nov 2017, 9:50 AM
dunfc
dunfc - avatar
0
Tinku
16th May 2023, 7:34 AM
Tinku Tinku
Tinku Tinku - avatar