HTML学习笔记

再来发一篇在Code Cademy上学习HTML的笔记。

Basic I

1. heading tags and paragraph

<body>
    <h1> head1 </h1>  # h1 这里表示heading tags, 类似的还有h2, h3, h4, h5, h6.
    <p> hi, this is paragraph. </p>   #这里p表示段落
</body>

显示结果如下:

Screen Shot 2015-03-17 at 3.11.08 PM.png

2. hyperlinks

<a href=""> </a>

<a href="http://www.codecademy.com">My Favorite Site!</a>

显示结果如下:

Screen Shot 2015-03-17 at 3.12.44 PM.png

3. images

show image : <img src=""/>
click image:

<a href="http://www.codecademy.com">
     <img src="http://s3.amazonaws.com/codecademy-blog/assets/f3a16fb6.jpg" />
</a>

显示结果如下:

Screen Shot 2015-03-17 at 3.13.26 PM.png

4. ordered lists

使用tag <ol>, 然后内部每个item用<li></li>包起来。

<ol>
    <li>Raindrops on roses</li>
    <li>Whiskers on kittens</li>
    <li>Bright copper kettles</li>
    <li>Warm woolen mittens</li>
</ol>

显示结果如下:

Screen Shot 2015-03-17 at 3.14.05 PM.png

5. unordered lists

使用tag <ul>,然后内部每个item用<li></li>包起来。

<h2>Taco Ingredients</h2> 
<ul>     
    <li>Cheese</li>     
    <li>Sour Cream</li> 
</ul>

显示结果如下:

Screen Shot 2015-03-17 at 3.14.33 PM.png

6. lists inside a list

lists是可以支持嵌套的。

<!DOCTYPE html>
<html>
    <head>
        <title>Nested lists</title>
    </head>
    <body>
        <ol>
            <li>Dad's interests 
            <ul>
                <li>football</li>
                <li>knitting</li>
            </ul></li>
            <li>Mom's interests 
            <ul>
                <li>hating football</li>
                <li>skydiving</li>
            </ul></li>
        </ol>
        <ul>
            <li>Favorite Boys' Names 
            <ol>
                <li>Tom</li>
                <li>Jason</li>
                <li>Thomas</li>
            </ol></li>
            <li>Favorite Girl' Names 
            <ol>
                <li>Lisa</li>
                <li>Angela</li>
                <li>Xindy</li>
            </ol></li>
        </ul>
    </body>
</html>

显示结果如下:

Screen Shot 2015-03-17 at 3.15.12 PM.png

7. making comments

<!— comment -->

8. font size

可以在opening tags中加入style属性来指定字体大小。

<p style="font-size: 10px"> Some text for you to make tiny! 
</p>

显示结果如下:

Screen Shot 2015-03-17 at 3.15.48 PM.png

9. font color

类似于font size,在style属性里也可以指定字体颜色。所有可用的colors列表参见这里:http://www.w3.org/TR/css3-color/#svg-color

<h1 style="color: green; font-size: 16px"> Big Heading </h1>

显示结果如下:

Screen Shot 2015-03-17 at 3.16.12 PM.png

10. font family

同上,还可以指定字体类型。所有可用的fonts列表参见这里:http://www.w3.org/TR/CSS21/fonts.html#generic-font-families

<li style="font-family: Arial; font-size: 16px">This item is big Arial.</li>

显示结果如下:

Screen Shot 2015-03-17 at 3.16.38 PM.png

11. background color

使用background-color属性。

<p style="background-color: yellow">Introduction</p>

显示结果如下:

Screen Shot 2015-03-17 at 3.17.42 PM.png

12. aligning the text

使用text-align属性。

<li style="text-align:left">list1</li>

显示结果如下:

Screen Shot 2015-03-17 at 3.19.03 PM.png

13. strong words

使用<strong></strong>将words包围起来,就能起到粗体的效果。

<p>Do you hear the people <strong>sing</strong>?</p>

显示结果如下:

Screen Shot 2015-03-17 at 3.19.31 PM.png

14. emphasize words

使用<em></em>将words包围起来,就能起到粗体的效果。

<p>Hey, don't say <em>that</em>!</p>

显示结果如下:

Screen Shot 2015-03-17 at 3.20.05 PM.png

Basic II

1. tables

<table>标签来创建表。
<tag>标签来创建表的一行。
<tag>标签里的<td>(table data)标签来创建表的一列。

<table border="1px">
    <tr>
        <td>King Kong</td>
        <td>1933</td>
    </tr>
    <tr>
        <td>Dracula</td>
        <td>1897</td>
    </tr>
    <tr>
        <td>Bride of Frankenstein</td>
        <td>1935</td>
    </tr>
</table>

显示结果如下:

Screen Shot 2015-03-17 at 3.20.36 PM.png

2. tables -- thead and tbody

<thead><tbody>标签类似于<head><body>标签,让table更醒目。

<html>
    <head>
        <title>Table Time</title>
    </head>
    <body>
        <table border="1px">
            <thead>
                <tr>
                    <th>Famous Monster</th>
                    <th>Birth Year</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>King Kong</td>
                    <td>1933</td>
                </tr>
                <tr>
                    <td>Dracula</td>
                    <td>1897</td>
                </tr>
                <tr>
                    <td>Bride of Frankenstein</td>
                    <td>1935</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

显示结果如下:

Screen Shot 2015-03-17 at 3.21.04 PM.png

3. tables -- naming

在原来<th>的基础上加入colspan属性,即可将一列扩展到多列,类似于合并单元格的功能。这样就能完成table的naming了。

<thead>
    <tr>
        <th colspan="2">Famous Monsters by Birth Year</th>
    </tr>
    <tr>
        <th>Famous Monster</th>
        <th>Birth Year</th>
    </tr>
</thead>

4. tables -- style that head

在table的相关tag中也可以加入style属性来给表格添加style。

<table style="border-collapse:collapse;">
    <thead>
        <tr>
            <th colspan="2" style="color: red">Famous Monsters by Birth Year</th>
        </tr>
        <tr style="border-bottom:1px solid black;">
            <th style="padding:5px;">
                <em>Famous Monster</em>
            </th>
            <th style="padding:5px;border-left:1px solid black;">
                <em>Birth Year</em>
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td style="padding:5px;">King Kong</td>
            <td style="padding:5px;border-left:1px solid black;">1933</td>
        </tr>
        <tr>
            <td style="padding:5px;">Dracula</td>
            <td style="padding:5px;border-left:1px solid black;">1897</td>
        </tr>
        <tr>
            <td style="padding:5px;">Bride of Frankenstein</td>
            <td style="padding:5px;border-left:1px solid black;">1944</td>
        </tr>
    </tbody>
</table>

显示结果如下:

Screen Shot 2015-03-17 at 3.21.58 PM.png

5. div

div即为division,可以创建容器。

<div style="width:50px; height:50px; background-color:red"></div>

显示结果如下:

Screen Shot 2015-03-17 at 3.22.40 PM.png

6. div -- link it

也可以用<a></a><div>包起来,这样整个div容器即变成可以linkable的了。

<a href="www.baidu.com">
    <div style="width:50px; height:50px; background-color:yellow"></div>
</a>

7. span

<span>允许我们来控制一些小的部分的style,例如一句话中将某个单词设置为特殊的颜色,特殊的字体。

<p>This text is black, except for the word <span style="font-family:Impact; color:red">red</span>!</p>

显示结果如下:

Screen Shot 2015-03-17 at 3.23.18 PM.png

8. recap

综合练习。

<!DOCTYPE html>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="stylesheet.css" />
        <title>My Photo Page</title>
    </head>
    <body>
        <table border="1px">
            <thead>
                <tr>
                    <th colspan="3" style="font-size:60px; color: blue; font-family:Impact">9 LOGOs</th>
                </tr>
            </thead>
            <tr>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
            </tr>
            <tr>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
            </tr>
            <tr>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
                <td>
                    <a href="www.baidu.com">
                        <img src="http://www.baidu.com/img/bdlogo.png" />
                    </a>
                </td>
            </tr>
        </table>
    </body>
</html>

显示结果如下:

Screen Shot 2015-03-17 at 3.25.16 PM.png

Reference

Code Cadecademy Web Course

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,847评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,208评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,587评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,942评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,332评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,587评论 1 218
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,853评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,568评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,273评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,542评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,033评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,373评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,031评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,073评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,830评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,628评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,537评论 2 269

推荐阅读更多精彩内容