<style type="css">

p.jin
{
text-align:center;
font:georgia;
font-size:20px;
color:blue;
}
</style>
<html>
<p class="jin">Summer Special</p>
</html>Quoted Text Here

Dani AI

Generated

Two quick points that explain why the CSS “didn’t work” and how to avoid the same trap again. Good move by to put the style block back into the document — browsers expect CSS inside the page (normally in the head or via an external file). Two less-obvious problems remained: the type attribute value in the original snippet was nonstandard, and the CSS used the font shorthand incorrectly. Both can cause browsers to ignore the rules.

Checklist (quick troubleshooting)

  • Use a proper HTML skeleton (doctype, head, body). Browsers are forgiving, but valid structure avoids weird parsing.
  • Put style rules in the head or use a linked stylesheet (<link rel="stylesheet" href="...">). In HTML5 the type attribute is optional; if present it must be the MIME type text/css — nonstandard values can stop the stylesheet from being applied.
  • Use correct properties: font-family for font names, and always give font size units (e.g., 20px). The shorthand font: requires multiple values and is easy to get wrong.
  • Verify your selector/class spelling (CSS needs . for classes, e.g., p.jin) and check specificity (later rules or inline styles win).
  • Clear cache or hard-reload and open DevTools to inspect the “Computed” styles and see which rule (if any) applied.

Example of a valid rule (CSS only)

p.jin {
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  color: #0000ff;
}

Notes: if styles still don’t show, confirm the stylesheet is loaded (check Network tab), ensure no syntax errors above the rule (a missing brace can break the rest), and remember inline styles or !important can override expected rules.

Recommended Answers

All 4 Replies

Don't put it outside of the HTML tag

It should be like this:

<html>
    <head>
        <!-- The STYLE tag should be put
                either inside the HEAD tag or the BODY tag.
                There's where the Browser's HTML parser expects it
                to be.
                -->
        <style type="css">
            p.jin {
                text-align:center;
                font:georgia;
                font-size:20px;
                color:blue;
            }
        </style>
    </head>
    <body>
        <p class="jin">Summer Special</p>
    </body>
</html>

oh,, i got it. thanks mate! :)

Anytime :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.