Home > Enterprise >  Why the Style tag is not working properly in HTML?
Why the Style tag is not working properly in HTML?

Time:12-29

I'm creating a webpage from scratch and I'm running into a problem

<html>

<head>
  <style>
    #ppp {
      font-style=italic;
    }
  </style>
</head>

<body>
  <p id="ppp">Italic</p>
  <b Style="color:red">red bold</b></br>
  some text
</body>

</html>

The text "Italic" should be italic, but is not

CodePudding user response:

Try this

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>

<style>
#ppp{
     font-style : italic;
}
</style>

</head>

<body>
    <p id="ppp">Italic</p>
    <b style="color:red">red bold</b>
    <br>
    some text
</body>

</html>

CodePudding user response:

bro the '=' sign that you have used is not the proper syntax you have to use colon ':' instead of that. It will fix your code most probably if all you want is to print in Italics

CodePudding user response:

change following portion in your code like this:

font-style : italic;

CodePudding user response:

Th issue is that your Css is not valid It should be

font-style: italic; with a ":"

<html>

<head>
  <style>
    #ppp {
      font-style:italic;
    }
  </style>
</head>

<body>
  <p id="ppp">Italic</p>
  <b style="color:red">red bold</b></br>
<p>some text<p>
</body>

</html>

CodePudding user response:

<html>

<head>
  <style>
    #ppp {
      font-style=italic;
    }
  </style>
</head>

<body>
  <p id="ppp">Italic</p>
  <b Style="color:red">red bold</b></br>
  some text
</body>

</html>

CodePudding user response:

Using the tag, that tag must be inside the tag. Using inline style, that tag must be inside an HTML element, for example: Megan McMullin .

  • Related