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有助于可访问性和搜索引擎优化。它也会影响您如何编写CSS,因为它们是紧密联系在一起的。前端web开发是指在浏览器中运行的语言。当这三种语言一起工作时,它们各自负责不同的事情。

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是用来添加交互性的,比如点击一个图片画廊,或者用一个按钮点击或者一个页面滚动来动态改变内容。那么,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.
每个新版本都添加或删除了特性,并且语法规则也发生了变化。这些标准由万维网联盟维护。你可以在w3.org网站上找到HTML和CSS的所有文档、指南和建议。下面是关于最新的HTML5特性和更改的其他一些特定资源。Mozilla开发者网络有一些关于视频和音频内容的信息。
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站点上的文档更详细地介绍了规范和特性。在HTML5中也添加了Canvas元素。在将其与JavaScript相结合时,它还允许使用代码绘制图形的更多方式,这也是Mozilla开发人员网络上的文档。它有一些基本的例子,以及一些其他资源的链接。
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.
它们通常成对出现并包装内容以赋予它意义。在元素的开头添加了开始标记,结束标记,加上一个正斜杠,标志着结束。这条规则有一些例外。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标签创建一个水平规则,它看起来就像一条线,并且经常被用来分隔文本块,不需要任何其他信息。另一方面,图像需要两个属性。一个源属性来链接和载入图像文件,以及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时创建的树状结构。
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阅读 203,098评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,213评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,960评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,519评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,512评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,533评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,914评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,574评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,804评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,563评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,644评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,350评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,933评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,908评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,146评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,847评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,361评论 2 342

推荐阅读更多精彩内容