html基础2——div,form, span等

    科技2025-11-05  16

    文章目录

    html基础2block level elementsdiv元素 inline elementsspan元素 form其他类型元素

    html基础2

    block level elements

    包括h1, form, li, ol, ul, p, pre, table, div等等

    div元素

    <div>元素常常被用来作为其他元素的容器,在结合css样式后,div元素可以来涉及整个代码块的风格。 例子(蓝底白字边缘填充):

    <html> <body> <h1>headline</h1> <div style="background-color:green;color:white; padding:20px;"> <p>Some paragraph text goes here</p> <p>Another paragraph goes here</p> </div> </body> </html>

    inline elements

    包括b, a, strong, img, input, em, span等

    span元素

    span常被作为行内元素的容器,结合css样式,可以设计一部分字符的样式等。 例子(蓝底白字边缘填充):

    <html> <body> <h1>headline</h1> some<span style="background-color:green;color:white;">important</span>message </body> </html>

    form

    form元素常被用于向服务器提交信息。 type包括text, password, radio, checkbox, submit等,radio是多选一,checkbox允许多选,submit提交信息 下面展示一个静态的form,需要结合后端语言如php来处理信息。

    <form action="url" method="GET"> <input type="text" name="username" placeholder="Name"><br> <input type="password" name="password" placeholder="Password"><br> <input type="radio" name="gender" value="male">Male<br> <input type="radio" name="gender" value="female">Female<br> <input type="checkbox" name="gender" value="1">Male<br> <input type="checkbox" name="gender" value="2">Female<br> <textarea name="message"></textarea> <input type="submit" name="submit"> </form>

    其他类型元素

    APPLET - embedded java appletIFRAME - inline frameINS - inserted textMAP - image mapOBJECT - embedded objectSCRIPT - script within an HTML document
    Processed: 0.018, SQL: 8