-1
<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <style type="text/css">
            body * {display:block;color:blue;}
        </style>
    </body>
</html>

my code is above, i realy need css in body, but in chrome it looks like this:

enter image description here

what's wrong with my code? and if I change body * {display:block;color:blue;} to body input {display:block;color:blue;} every thing will be ok

--------------------------------------------------------------------------------

I use Java for web development, my template engine is freemaker I define a macro like this:

<#macro Page >
    <!DOCTYPE html>
    <html>
    <head>  
        <meta ...>
        <link ...>
        <tile ...>
        <script ..>
    </head>
    <body>
        <#nested>
    </body>
    </html>
</#macro>

so when I create a page, I can just use

<@Page>
    <style>...</style><div...>    <--- this will put in to html body
</@Page>

that' why i have to put css in body

lionyu
  • 593
  • 3
  • 5
  • 14
  • 2
    Possible duplicate of [Using – thepio Feb 17 '17 at 08:35

3 Answers3

0

The 'style' tag needs to be placed in the 'head' area:

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            body * {display:block;color:blue;}
        </style>
    </head>
    <body>
    </body>
</html>

Maybe this Using <style> tags in the <body> with other HTML post helps you.

Community
  • 1
  • 1
dns_nx
  • 3,651
  • 4
  • 37
  • 66
0

I think what java don't understand the '*', try use this:

body h1, body h2, body h3, body h4, body h5, body h6, body div, body span, body p, .... etc... {
  display:block;color:blue;
}
grinmax
  • 1,835
  • 1
  • 10
  • 13
0

body * {display:block;color:blue;} will make every in body to display in block , and <style> is in body, so just like body style {display:block;color:blue;}

lionyu
  • 593
  • 3
  • 5
  • 14