代碼編輯器使用

編輯器裡點選 javascript 、 CSS 、 html 可切換代碼,Result 展示效果
顯示具有 HTML5 標籤的文章。 顯示所有文章
顯示具有 HTML5 標籤的文章。 顯示所有文章

2014年4月11日 星期五

HTML5 Input標籤

HTML5 新的 Input 類型

HTML5 擁有多的表單輸入類型。這些新特性提供了更好的控制和驗證。
目前主流瀏覽器都可使用,但IE8以下無法使用。

1. email
在送出表單時,會自動驗證 email 的值。

2. url
在送出表單時,會自動驗證 url 的值。

3. number
在表單中只能夠輸入數字。
另外可以配合 min 、max 、step 、value
屬性 值 描述
min number 最小值
max number 最大值
step number 規定合法數字區間(如:step=2 value=2、4、6、8...)
value number 規定數字

4. range
輸入包含一定範圍內的數字,只是顯示為滑動條。
同樣可輸入屬性同 number 。

5. Date Pickers(日期選擇器)
產生日期選擇器。
類型 描述
date 選取日、月、年
month 選取月、年
week 選取週、年
time 選取時間
datetime-local 選取時間、日、月、年(本地)

下面有代碼和展示效果

2014年3月4日 星期二

HTML5 基本架構

style.css
header, nav, section, article, footer {
    display: block;
}
header, nav, section, article, footer {
    color: white;
}
header, footer {
    text-align: center;
    width: 100%;
}
header {
    background-color: red;
    font-size: 36px;
    font-weight: bold;
}
nav {
    position: fixed;
    top: 50px;
    right: 25px;
    background-color: blue;
    width: 100px;
}
section {
    width: 100%;
    background-color: gray;
}
article {
    padding: 20px;
}
footer {
    background-color: green;
    font-size: 10px;
}

demo.html
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <link rel="stylesheet" type="text/css" href="style.css" />
        <title>HTML 5 DEMO</title>
    </head>
    <body>
        <header>
            header
        </header>
        <nav>
            <ul>
                <li>nav 1</li>
                <li>nav 2</li>
            </ul>
        </nav>
        <section>
            <article>
                <details>
                    <summary>Some details</summary>
                    <p>More info about the details.</p>
                </details>
            </article>
        </section>
        <footer>footer © 2014</footer>
    </body>
</html>

<!DOCTYPE html>是告訴瀏覽器這份html文件是HTML5

<header> 為 HTML5 文件置頂的描述區域, <nav> 為導覽區塊,通常用作側邊欄, <section> 為內容區域,裡頭的段落文章再用 <article> 標記,因此一個 <section> 可以有多個 <article> , <details> <summary> 為互動式表單元素, <footer> 則是置底的描述區域。

結果畫面
參考資料