HTML常用标签及约束

来源:互联网 发布:小米 金属 贵 知乎 编辑:程序博客网 时间:2024/06/07 18:46
  • 注释

    <--!这是一段注释-->
  • 样式表

    • 外部样式(CSS)

      <head><link rel="stylesheet" type="text/css" href="mystyle.css"></head>
    • 内部样式

      <head><style type="text/css">body {background-color: red}p {margin-left: 20px}</style></head>
  • 标题

    <h1>这是一个标题</h1>

    标题范围为可为h1~h6。

  • 段落

    <p>这是一个段落</p>

    段落内换行需使用<br />标签。
    若希望实现对空格与换行符的保留则可使用<pre></pre>标签。

    <pre>   hello, how are you?</pre>
  • 图片

    <img src="url" />
  • 链接

    <a href="url" target="_blank"><img src="url"></a>

    以上链接会在新标签页中显示,由target = “blank”这一属性定义。
    此链接被置于来源为url地址的图片上。

  • 列表

    • 无序(号)列表

      <ul><li>Apple</li><li>Boy</li></ul>
    • 有序(号)列表

      <ol><li>Apple</li><li>Boy</li></ol>
    • <span>

      <p><span class="tip">提示:</span>...</p>
    • <div>

      <p><div class="tip">提示:...</div></p>
  • 表单

    <form method="POST" action="action_page.php">Username:<br /><input type="text" name="username"><br />Password:<br /><input type="password" name="password"><br /><input type="submit" value="submit"></form>

    关于method的选择:POST安全性好,GET适合少量数据提交。
    具有name属性的表单元素才会被提交。

原创粉丝点击