`
happysalay
  • 浏览: 10731 次
  • 性别: Icon_minigender_1
  • 来自: 济南
最近访客 更多访客>>
社区版块
存档分类
最新评论

HTML Elements

    博客分类:
  • java
阅读更多

转载

HTML documents are defined by HTML elements.


HTML Elements

An HTML element is everything from the start tag to the end tag:

Start tag * Element content End tag *
<p> This is a paragraph </p>
<a href="default.htm" > This is a link </a>
<br />    

* The start tag is often called the opening tag. The end tag is often called the closing tag.


HTML Element Syntax

  • An HTML element starts with a start tag / opening tag
  • An HTML element ends with an end tag / closing tag
  • The element content is everything between the start and the end tag
  • Some HTML elements have empty content
  • Empty elements are closed in the start tag
  • Most HTML elements can have attributes

Tip: You will learn about attributes in the next chapter of this tutorial.


Nested HTML Elements

Most HTML elements can be nested (can contain other HTML elements).

HTML documents consist of nested HTML elements.


HTML Document Example

<html>

<body>
<p>This is my first paragraph.</p>
</body>

</html>

The example above contains 3 HTML elements.


HTML Example Explained

The <p> element:

<p>This is my first paragraph.</p>

The <p> element defines a paragraph in the HTML document.
The element has a start tag <p> and an end tag </p>.
The element content is: This is my first paragraph.

The <body> element:

<body>
<p>This is my first paragraph.</p>
</body>

The <body> element defines the body of the HTML document.
The element has a start tag <body> and an end tag </body>.
The element content is another HTML element (a p element).

The <html> element:

<html>

<body>
<p>This is my first paragraph.</p>
</body>

</html>

The <html> element defines the whole HTML document.
The element has a start tag <html> and an end tag </html>.
The element content is another HTML element (the body element).


Don't Forget the End Tag

Most browsers will display HTML correctly even if you forget the end tag:

<p>This is a paragraph
<p>This is a paragraph

The example above will work in most browsers, but don't rely on it. Forgetting the end tag can produce unexpected results or errors.

Note: Future version of HTML will not allow you to skip end tags.


Empty HTML Elements

HTML elements with no content are called empty elements. Empty elements can be closed in the start tag.

<br> is an empty element without a closing tag (the <br> tag defines a line break).

In XHTML, XML, and future versions of HTML, all elements must be closed.

Adding a slash to the start tag, like <br />, is the proper way of closing empty elements, accepted by HTML, XHTML and XML.

Even if <br> works in all browsers, writing <br /> instead is more future proof.


HTML Tip: Use Lowercase Tags

HTML tags are not case sensitive: <P> means the same as <p>. Many web sites use uppercase HTML tags.

W3Schools use lowercase tags because the World Wide Web Consortium (W3C)recommends lowercase in HTML 4, and demands lowercase tags in future versions of (X)HTML.

分享到:
评论

相关推荐

    htmlelements:Html Elements是一个Java框架,提供了易于使用的与网页测试中的网页元素进行交互的方式

    HTML Elements框架 该框架旨在提供一种易于使用的与测试中的网页元素进行交互的方式。 它可以被认为是WebDriver页面对象的扩展。 借助Html Elements框架,您可以将网页元素分组为块,在其中封装交互逻辑,然后轻松...

    Zen HTML Elements 使用zen coding的朋友可以收藏下

    html¶ &lt;html&gt;&lt;/html&gt; html:xml¶ &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"&gt;&lt;/html&gt; html:4t¶ &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ...

    Remove HTML Elements-crx插件

    只需单击一下即可轻松地删除所需HTML5元素! 删除HTML元素add-On允许您在任何HTML5网页中轻松删除所需的元素。 只需单击工具栏按钮即可激活加载项。 请注意,此附加加载需要“用户操作”要激活。 有效后,请使用鼠标...

    HTML Elements Screenshot-crx插件

    HTML Elements屏幕快照使您可以从任何网页捕获全部或部分屏幕截图。 它使用一个名为html2canvas的开源JavaScript库。 为了使用该附加组件,只需单击工具栏图标以激活该附加组件。 然后,用鼠标左键选择任何所需的...

    Selenium.HtmlElements.Net:Selenium.WebDriver的元素模型

    HtmlElements是.NET库,通过允许您创建更复杂和复杂的页面对象,对页面对象模型进行了补充。 它还为常用HTML元素(链接,输入字段,图像,框架等),备用等待语法,智能框架和一些其他有用的实用程序提供了一组标准...

    HTML - Beginners-Guide-to-HTML - Michael Gabriel

    2.2 HTML elements 2.3 Tips 2.4 Attributes 3. Titles. Headings. Paragraphs. 3.1 The title tag 3.2 Headings 3.3 Paragraphs 4. Unnumbered, Numbered, Definition and Nested Lists 4.1 Ordered lists 4.2 ...

    HTML Document HTML Document HTML Document

    "HTML元素参考手册 HTML Elements Reference 网页教程与代码 站长网教程中心_www_admin5_com-html.htm"则可能是一份详尽的HTML元素参考手册,包含了所有HTML元素的详细说明、用法示例和代码片段。这份手册可能帮助...

    Divelements.SilverlightTools工具

    《Divelements.SilverlightTools工具:HTML容器的深度解析》 Divelements.SilverlightTools是一款专为Silverlight开发者设计的强大工具集,它极大地扩展了Silverlight的应用潜力,尤其在处理HTML容器方面表现突出。...

    《HTML5CSSJavaScript深入学习实录》读书笔记模板x.pptx

    在 HTML 部分,书中对 HTML 的基础知识进行了详细的介绍,包括 HTML 的基本结构、HTML elements、HTML 属性、HTML 事件等。此外,书中还对 HTML5 的新特性进行了介绍,包括新的 HTML elements、新的 API 等。 在 ...

    html入门教程适合初学者.docx

    2. HTML元素(HTML Elements): HTML元素是构成网页的基本单元,它们由一对标签(Opening Tag和Closing Tag)定义,如`&lt;p&gt;`和`&lt;/p&gt;`表示一个段落。元素可以有属性,比如`&lt;body bgcolor="red"&gt;`,其中`bgcolor`是...

    HTML Manual of Style, 4th Edition

    Book Description THE CLASSIC WEB AUTHORING GUIDE, NOW 100% UPDATED AND BETTER THAN...Contains quick reference guides to HTML elements and CSS properties–including the newest HTML5 and CSS3 improvements!

    HTML 4.0 Reference.chm

    HTML 4.0的英文参考手册 初学者的参考用书

    HTML教程--网页教程与代码.doc

    HTML文件由一系列的元素(HTML Elements)组成,这些元素通过标签(Tag)来表示,标签通常成对出现,如`&lt;tag&gt;`和`&lt;/tag&gt;`,用来包裹网页内容。 HTML的基本概念包括: 1. **HTML文件**:HTML文件是一种包含文本内容...

    Beginning HTML5 and CSS3 For Dummies

    Heads and bodies — dive head-first into HTML elements, add paragraphs (and other containers) for text, and create lists and tables Get engaged — entice your visitors with links, images, audio, video...

Global site tag (gtag.js) - Google Analytics