How can I put CSS and HTML code in the same file?

后端 未结 6 1529
心在旅途
心在旅途 2020-12-24 07:12

I\'m a profane in CSS, I don\'t know anything about it. I need to put HTML code and the CSS formatting for it in the same string object for an iPhone program.

I have

相关标签:
6条回答
  • 2020-12-24 07:27

    Or also you can do something like this.

    <div style="background=#aeaeae; float: right">
    
    </div>
    

    We can add any CSS inside the style attribute of HTML tags.

    0 讨论(0)
  • 2020-12-24 07:27

    Two options: 1, add css inline like style="background:black" Or 2. In the head include the css as a style tag block.

    0 讨论(0)
  • 2020-12-24 07:34

    You can include CSS styles in an html document with <style></style> tags.

    Example:

    <style>
      .myClass { background: #f00; }
    
      .myOtherClass { font-size: 12px; }
    </style>
    
    0 讨论(0)
  • 2020-12-24 07:34

    Is this what you're looking for? You place you CSS between style tags in the HTML document header. I'm guessing for iPhone it's webkit so it should work.

    <html>
    <head>
        <style type="text/css">
        .title { color: blue; text-decoration: bold; text-size: 1em; }
        .author { color: gray; }
        </style>
    </head>
    <body>
        <p>
        <span class="title">La super bonne</span>
        <span class="author">proposée par Jérém</span>
        </p>
    </body>
    </html>
    
    0 讨论(0)
  • 2020-12-24 07:40

    There's a style tag, so you could do something like this:

    <style type="text/css">
      .title 
      {
        color: blue;
        text-decoration: bold;
        text-size: 1em;
      }
    </style>
    
    0 讨论(0)
  • 2020-12-24 07:49
    <html>
    <head>
        <style type="text/css">
        .title {
            color: blue;
            text-decoration: bold;
            text-size: 1em;
        }
    
        .author {
            color: gray;
        }
        </style>
    </head>
    <body>
        <p>
        <span class="title">La super bonne</span>
        <span class="author">proposée par Jérém</span>
        </p>
    </body>
    </html>
    

    On a side note, it would have been much easier to just do this.

    0 讨论(0)
提交回复
热议问题