0

I'm trying to set background color to blue using javascript ran with Sublime Text 3. What command should I be using. Thank you

<!DOCTYPE HTML>
<html>
    <head>
        <style type="text/css">
        </style>
    </head>
    <body>
        <backgroundColor="blue>;
        </backgroundColor="blue"> 
    </body>
</html> 

3 Answers3

0

<style> tag is used to declare CSS properties in the same HTML document.

<!DOCTYPE HTML>
<html>
    <head>
        <style type="text/css">
            .blueDiv
            {
                background-color: blue;
            }
        </style>
    </head>
    <body>
        <div class="blueDiv">
            Background color of this div is blue.
        </div> 
    </body>
</html> 
Aycan Yaşıt
  • 2,106
  • 4
  • 34
  • 40
0

You can use inline style with div to set background color:

    <!DOCTYPE HTML>
    <html>
        <head>
            <style type="text/css">
             .bg-blue{background-color:blue;}
            </style>
        </head>
        <body>
            <div class="bg-blue">
            </div>
        </body>
    </html> 
Girish Vadhel
  • 735
  • 1
  • 5
  • 17
0

Thank you guys, until now I tried this - in vain:

<!DOCTYPE>
<html>
<head>
      <meta content="text/html; charset=ISO-8859-1"
       http-equiv="content-type">
      <title>DropDown</title>

      <script language="javascript">
      fuction()
      $("select").change(function() {
      $(this).css("background-color", ($(this).attr("data-correctVal") == 
      $(this).val()) ? "green" : "red");
      });
      </script>
      </head>
      <body>
      <select name="Armaturen">
      <option value="1">&Ouml;lvorw&auml;rmung</option>
      <option value="2">Kesselthermostat</option>
      <option value="3">&Ouml;lpumpe</option>
      <option></option>
      </select>

      </body>
      </html>

Now I will try yours - patience please ... and thanks a lot!!!

Matt
  • 1