CSS1.1.1

Before we jump into CSS, let's start with a quick review of HTML. HTML is used to define the structure of a webpage and the meaning of the content to the browser. Using semantic HTML helps with accessibility and search engine optimization. It also effects how you write the CSS, since they are closely related together. Front end web development refers to the languages that run in the browser. While these three languages work together, they're each responsible for something different.
在進入CSS之前鄙早,讓我們先快速回顧一下HTML妹懒。HTML用于定義網頁的結構和瀏覽器內容的含義知染。使用語義HTML有助于可訪問性和搜索引擎優(yōu)化。它也會影響您如何編寫CSS羞秤,因為它們是緊密聯系在一起的。前端web開發(fā)是指在瀏覽器中運行的語言左敌。當這三種語言一起工作時瘾蛋,它們各自負責不同的事情。

HTML is the starting point, because it's used to add content and structure the page. CSS is for presentational effects and styles, such as colors and fonts. And JavaScript is used for adding interactivity, such as clicking through an image gallery, or dynamically changing content with a button click or a page scroll. So, what is HTML5, and how is it different from HTML or XHTML? These refer to different versions, with HTML5 being the latest.
HTML是起始點矫限,因為它用于添加內容和構造頁面哺哼。CSS是用于顯示效果和樣式佩抹,例如顏色和字體。JavaScript是用來添加交互性的取董,比如點擊一個圖片畫廊棍苹,或者用一個按鈕點擊或者一個頁面滾動來動態(tài)改變內容。那么茵汰,HTML5是什么枢里,它與HTML或XHTML有什么不同呢?這些是不同的版本,HTML5是最新的版本蹂午。
With each new version, features are added or removed, and syntax rules also change. These standards are maintained by the World Wide Web Consortium. You can find all the documentation, guidelines, and recommendations for HTML and CSS on their website at w3.org. And here are some other specific resources about the latest HTML5 features and changes. The Mozilla developer network has some information about the video and audio content.
每個新版本都添加或刪除了特性栏豺,并且語法規(guī)則也發(fā)生了變化。這些標準由萬維網聯盟維護画侣。你可以在w3.org網站上找到HTML和CSS的所有文檔冰悠、指南和建議。下面是關于最新的HTML5特性和更改的其他一些特定資源配乱。Mozilla開發(fā)者網絡有一些關于視頻和音頻內容的信息溉卓。
In HTML5, more support from media elements were integrated, making Flash a thing of the past. This documentation on the Mozilla site goes into greater detail about the specifications and features. The Canvas element was also added in HTML5. In combining this with JavaScript, it also allowed for more ways to draw graphics using code, which is also documented on the Mozilla developer network. It has some basic examples, as well as links to some further resources.
在HTML5中,更多來自媒體元素的支持被整合搬泥,讓Flash成為過去桑寨。Mozilla站點上的文檔更詳細地介紹了規(guī)范和特性。在HTML5中也添加了Canvas元素忿檩。在將其與JavaScript相結合時尉尾,它還允許使用代碼繪制圖形的更多方式,這也是Mozilla開發(fā)人員網絡上的文檔燥透。它有一些基本的例子沙咏,以及一些其他資源的鏈接。
There has also been the addition of new semantic HTML5 elements for defining your content, and HTML5 Doctor is a great resource to learn about the changes. Let's do a review of some HTML terminology and syntax. Getting a grasp on the terms makes it easier to ask clearer questions and find answers. Elements are the components that define page objects, such as paragraphs and links. Tags are used to define these elements, using angled brackets wrapped around the tag name.
此外班套,還添加了新的語義HTML5元素來定義內容肢藐,而HTML5博士是了解這些變化的重要資源。讓我們來回顧一下一些HTML術語和語法吱韭。掌握這些術語會讓你更容易問清楚問題吆豹,并找到答案。元素是定義頁面對象的組件理盆,例如段落和鏈接痘煤。標記用于定義這些元素,使用帶有標記名稱的尖括號猿规。
They usually come in pairs and wrap the content to give meaning to it. The opening tag is added at the beginning of the element, and the closing tag, with the addition of a forward slash, marks the end. There are some exceptions to this rule. Void elements don't have closing tags and don't wrap any content, because they are the content. But, there aren't many void elements, and here's the full list. Visit the W3C for more information about each tag.
它們通常成對出現并包裝內容以賦予它意義衷快。在元素的開頭添加了開始標記,結束標記坎拐,加上一個正斜杠烦磁,標志著結束养匈。這條規(guī)則有一些例外。Void元素沒有結束標記都伪,也沒有包裝任何內容呕乎,因為它們是內容。但是陨晶,這里沒有很多空元素猬仁,這里是完整列表。訪問W3C獲得關于每個標簽的更多信息先誉。
Some void elements can be used on their own, and others require additional information. For example, the HR tag creates a horizontal rule, which looks just like a line, and is often used to separate blocks of text and does not require any other information. Images, on the other hand, requires two attributes. A source attribute to link to and load the image file, and the alt attribute, to provide a short description about the image for screen readers.
一些void元素可以單獨使用湿刽,而其他元素則需要額外的信息。例如褐耳,HR標簽創(chuàng)建一個水平規(guī)則诈闺,它看起來就像一條線,并且經常被用來分隔文本塊铃芦,不需要任何其他信息雅镊。另一方面,圖像需要兩個屬性刃滓。一個源屬性來鏈接和載入圖像文件仁烹,以及alt屬性,為屏幕閱讀器提供一個關于圖像的簡短描述咧虎。
You may have also seen void elements written with a forward slash at the end of the tag. This is one of those HTML5 syntax changes. It was required in the previous version, XHTML, but is no longer needed. HTML5 is actually backwards compatible, so if you leave it in, that works as well. There are many different attributes used to provide additional information. They always follow the format of attribute name equals the value contained in single or double quotes.
您可能還看到了在標記的末尾用斜杠編寫的void元素卓缰。這是HTML5語法中的一個變化。它在以前的版本XHTML中是必需的砰诵,但現在不再需要了征唬。HTML5實際上是向后兼容的,所以如果你把它放進去茁彭,它也可以鳍鸵。有許多不同的屬性用于提供額外的信息。它們總是遵循屬性名的格式尉间,等于單引號或雙引號中包含的值。
The values vary depending on the attribute. Another common one is the HREF attribute, used to add the address for the link reference. You can also have more than one attribute per tag. It doesn't matter what order you put them in, just be sure to separate them with a space. We'll be looking at a few more attributes, specifically for CSS, in the upcoming lessons. The document object model represents the tree-like structure that is created when writing HTML.
值根據屬性不同而不同击罪。另一個常見的是HREF屬性哲嘲,用于添加鏈接引用的地址。每個標簽也可以有多個屬性媳禁。不管你把它們放在什么順序眠副,一定要把它們和空間分開。在接下來的課程中竣稽,我們將會看到更多的屬性囱怕,特別是CSS霍弹。文檔對象模型表示在編寫HTML時創(chuàng)建的樹狀結構。
Each element is an object, which makes up the document, hence the name, document object model. Elements are often nested, meaning the tags are written inside of other tags. This creates relationships resembling a family tree. Branches of ancestors, descendants, parents, children, and sibling nodes. Understanding this model is necessary for writing CSS. And here's a little pro tip.
每個元素都是一個對象娃弓,它構成了文檔典格,因此命名為document object model。元素通常是嵌套的台丛,這意味著標簽是在其他標簽的內部寫的耍缴。這就產生了一種類似于族譜的關系。祖先挽霉、后代防嗡、父母、孩子和兄弟姐妹的分支侠坎。理解這個模型是編寫CSS的必要條件蚁趁。這里有個小建議。
Use white space and indentation to visually show which elements are nested. This is just a short example, but indentation will make the code easier to read as your pages get longer and longer.
使用空白和縮進來直觀地顯示哪些元素是嵌套的实胸。這只是一個簡短的例子他嫡,但是縮進將使代碼更容易閱讀,因為您的頁面變得越來越長童芹。

?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末涮瞻,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子假褪,更是在濱河造成了極大的恐慌署咽,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,525評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件生音,死亡現場離奇詭異宁否,居然都是意外死亡,警方通過查閱死者的電腦和手機缀遍,發(fā)現死者居然都...
    沈念sama閱讀 93,203評論 3 395
  • 文/潘曉璐 我一進店門慕匠,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人域醇,你說我怎么就攤上這事台谊。” “怎么了譬挚?”我有些...
    開封第一講書人閱讀 164,862評論 0 354
  • 文/不壞的土叔 我叫張陵锅铅,是天一觀的道長。 經常有香客問我减宣,道長盐须,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,728評論 1 294
  • 正文 為了忘掉前任漆腌,我火速辦了婚禮贼邓,結果婚禮上阶冈,老公的妹妹穿的比我還像新娘。我一直安慰自己塑径,他們只是感情好女坑,可當我...
    茶點故事閱讀 67,743評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著晓勇,像睡著了一般堂飞。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上绑咱,一...
    開封第一講書人閱讀 51,590評論 1 305
  • 那天绰筛,我揣著相機與錄音,去河邊找鬼描融。 笑死铝噩,一個胖子當著我的面吹牛,可吹牛的內容都是我干的窿克。 我是一名探鬼主播骏庸,決...
    沈念sama閱讀 40,330評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼薪丁,長吁一口氣:“原來是場噩夢啊……” “哼撞鹉!你這毒婦竟也來了尚揣?” 一聲冷哼從身側響起熟妓,我...
    開封第一講書人閱讀 39,244評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎搔涝,沒想到半個月后拖云,有當地人在樹林里發(fā)現了一具尸體摘仅,經...
    沈念sama閱讀 45,693評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡跃惫,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,885評論 3 336
  • 正文 我和宋清朗相戀三年叮叹,在試婚紗的時候發(fā)現自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片爆存。...
    茶點故事閱讀 40,001評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡蛉顽,死狀恐怖,靈堂內的尸體忽然破棺而出先较,到底是詐尸還是另有隱情携冤,我是刑警寧澤,帶...
    沈念sama閱讀 35,723評論 5 346
  • 正文 年R本政府宣布闲勺,位于F島的核電站噪叙,受9級特大地震影響,放射性物質發(fā)生泄漏霉翔。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,343評論 3 330
  • 文/蒙蒙 一苞笨、第九天 我趴在偏房一處隱蔽的房頂上張望债朵。 院中可真熱鬧子眶,春花似錦、人聲如沸序芦。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,919評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽谚中。三九已至渴杆,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間宪塔,已是汗流浹背磁奖。 一陣腳步聲響...
    開封第一講書人閱讀 33,042評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留某筐,地道東北人比搭。 一個月前我還...
    沈念sama閱讀 48,191評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像南誊,于是被迫代替她去往敵國和親身诺。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,955評論 2 355

推薦閱讀更多精彩內容