1

I have a problem where any text in the content div wont style.

I have tried(not all at the same time)

#content p{ margin-left: 5px; }
p{ margin-left: 5px; }

but when I style it directly it will work e.g.

<p style="margin-left: 5px;">Test</p>

HTML/PHP code

<!DOCTYPE html>
<html>
<head>
    <?php require('headers.php'); ?>
    <title>Title</title>
</head>
<body>
    <?php include('nav.php'); ?>
    <div id="content">
        <p>This is some sample text</p>
    </div>
</body>
</html>

CSS

*{
margin: 0;
padding: 0;
}

html{
font-family: 'Open Sans', sans-serif;
}

body{
}

--snip nav styling--

#content{
margin: 0 auto;
width: 900px;
background-color: lightgrey;
}

#content p{
margin-left: 5px;
}

FIX I found that when I transfer the files to the server styles.css wasn't being changed. Delete and re upload solved the problem.

oliverjrose99
  • 47
  • 1
  • 8

1 Answers1

2

Are you using the double dashes as quotes in your actual code? That'll be why it isn't recognising the rule for #content p.

Comments in CSS are done with using forward-slash and an asterisk, like so:

/* This is a valid CSS comment */

You can also comment out lines using double-slashes, but it isn't advised.

// This is also technically a valid comment, but shouldn't be used.

Interestingly enough with your code is that is has only ignored the rule that is immediately after the "comment", so the margin-left: 5px on the p element is still applied - as seen here.

Community
  • 1
  • 1
lewisj
  • 95
  • 1
  • 8
  • I cut out the nav styling as that works but it is in the full file – oliverjrose99 Apr 26 '15 at 22:23
  • Right, I completely misunderstood that - sorry! Is there anything within the nav styling that might be overriding the styling you are making further down? – lewisj Apr 26 '15 at 22:26
  • What browsers are you guys using? –  Apr 26 '15 at 22:28
  • Firefox, I have tried clearing cache and Ctrl+F5 reloading the page – oliverjrose99 Apr 26 '15 at 22:29
  • Have you tried my answer? If that does not work than there is something else going on. Try some greater values like 150. You might not notice 5px difference on you screen. –  Apr 26 '15 at 22:32
  • Yes, the padding works, but the margin is working in the JSFiddle I posted as well (Firefox 37.0.2). I can't see why it isn't working for @user3866695 at the moment. – lewisj Apr 26 '15 at 22:34