0

Seems my CSS class defined in the head of the document isn't being recognized or applied. Any idea what I'm missing, or doing wrong?

JS Fiddle

<html>
  <head>
      <title>EXAMPLE</title>
      <style>
          .show_x
          {
              visibility: visible;
          }
          //
          .hide_x
          {
              visibility: hidden;
          }
      </style>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script
  src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>
  <body>
        <span class="hide_x glyphicon glyphicon-warning-sign text-danger"></span>
        <span class="glyphicon glyphicon-warning-sign text-danger" style="visibility: hidden;"></span>
    </body>
</html>

I would expect to see neither warning sign, but I see the first one. The second one is properly hidden.

4
  • you have two closing </head> tags, I'd start with addressing that first and see if it helps. I'm assuming there is a single </html> closing tag that isn't shown in your sample. Commented Dec 19, 2018 at 19:03
  • 5
    Why is there a "//". When I remove it in the debugger, the css works as expected. Commented Dec 19, 2018 at 19:05
  • And that was it. Silly type-o. Thanks Commented Dec 19, 2018 at 19:08
  • check this updated jsfiddle jsfiddle.net/ewajhm49/11 Commented Dec 19, 2018 at 19:10

2 Answers 2

4

Inline comments do not work in CSS, so where you have

      .show_x
      {
          visibility: visible;
      }
      // <-- invalid CSS
      .hide_x
      {
          visibility: hidden;
      }

Which probably makes the browser stop processing that CSS block, conveniently right before the more visible of the two (or less visible) ... anyway the one that's easier to see when it's applied as it hides stuff ... you get what I mean.

In CSS we can use only block comments /**/, it's a simple mistake.

Sign up to request clarification or add additional context in comments.

Comments

1

<html>
  <head>
      <title>EXAMPLE</title>
      <style>
          .show_x
          {
              visibility: visible;
          }
        
          .hide_x
          {
              visibility: hidden;
          }
      </style>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script
  src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>
  <body>
        <span class="hide_x glyphicon glyphicon-warning-sign text-danger"></span>
        <span class="glyphicon glyphicon-warning-sign text-danger" style="visibility: hidden;"></span>
    </body>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.