首页 > 其他分享 >HTML 03 - Basic Tags

HTML 03 - Basic Tags

时间:2024-05-13 19:42:30浏览次数:24  
标签:03 use HTML Tags text Example tag example

HTML - Basic Tags

 

HTML tags are the fundamental elements of HTML used for defining the structure of the document. These are letters or words enclosed by angle brackets (< and >).

Usually, most of the HTML tags contains an Opening and a Closing tag. Each tag has a different meaning and the browser reads the tags and displays the contents enclosed by it accordingly.

For example, if we wrap any text with in the paragraph (<p></p>) tag browser displays it as a separate paragraph. In this tutorial we will discuss all the basic tags in HTML.

Heading Tags

Any document starts with a heading. You can use different sizes for your headings. HTML also has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>. While displaying any heading, browser adds one line before and one line after that heading.

Example

Following HTML example demonstrates various levels of headings −

 
<!DOCTYPE html>
<html>
<head>
   <title>Heading Example</title>
</head>
<body>
   <h1>This is heading 1</h1>
   <h2>This is heading 2</h2>
   <h3>This is heading 3</h3>
   <h4>This is heading 4</h4>
   <h5>This is heading 5</h5>
   <h6>This is heading 6</h6>
</body>
</html>

 

Paragraph Tag

The <p> tag offers a way to structure your text into different paragraphs. Each paragraph of text should go in between an opening <p> and a closing </p> tag as shown below in the example −

Example

<!DOCTYPE html>
<html>
<head>
   <title>Paragraph Example</title>
</head>
<body>
   <p>Here is a first paragraph of text.</p>
   <p>Here is a second paragraph of text.</p>
   <p>Here is a third paragraph of text.</p>
</body>
</html>

 

Line Break Tag

Whenever you use the <br /> element, anything following it starts from the next line. This tag is an example of an empty element, where you do not need opening and closing tags, as there is nothing to go in between them.

The <br /> tag has a space between the characters br and the forward slash. If you omit this space, older browsers will have trouble rendering the line break, while if you miss the forward slash character and just use <br> it is not valid in XHTML.

Example

<!DOCTYPE html>
<html>
<head>
   <title>Line Break Example</title>
</head>
<body>
   <p>Hello<br /> You delivered your assignment on time.<br />
      Thanks<br /> Mahnaz</p>
</body>
</html>

 

Centering the Content

You can use <center> tag to put any content in the center of the page or any table cell.

Example

 
<!DOCTYPE html>
<html>
<head>
   <title>Centering Content Example</title>
</head>
<body>
   <p>This text is not in the center.</p>
   <center>
      <p>This text is in the center.</p>
   </center>
</body>
</html>

 


Horizontal Lines

Horizontal lines are used to visually break-up sections of a document. The <hr> tag creates a line from the current position in the document to the right margin and breaks the line accordingly.

Example

Following example draws a horizontal line between two paragraphs −

 
<!DOCTYPE html>
<html>
<head>
   <title>Horizontal Line Example</title>
</head>
<body>
   <p>This is paragraph one and should be on top</p>
   <hr />
   <p>This is paragraph two and should be at bottom</p>
</body>
</html>

 

On executing the above example, you can see a straight line dividing the two paragraphs.

The <hr /> tag is an example of the empty element, where you do not need opening and closing tags, as there is nothing to go in between them.

The <hr /> element has a space between the characters hr and the forward slash. If you omit this space, older browsers will have trouble rendering the horizontal line, while if you miss the forward slash character and just use <hr> it is not valid in XHTML

 

Preserve Formatting

Sometimes, you want your text to follow the exact format of how it is written in the HTML document. In these cases, you can use the preformatted tag <pre>.

Any text between the opening <pre> tag and the closing </pre> tag will preserve the formatting of the source document.

Example

 
<!DOCTYPE html>
<html>
<head>
   <title>Preserve Formatting Example</title>
</head>
<body>
   <pre>
      function testFunction( strText ){
         alert (strText)
      }
   </pre>
</body>
</html>

 

If you execute the same code without using the <pre>...</pre> tags. The function will be displayed without the predefined format as shown below −

function testFunction( strText ){ alert (strText) }

 

Nonbreaking Spaces

Suppose, if you want to use the phrase "12 Angry Men." Here, you would not want a browser to split the "12, Angry" and "Men" across two lines −

An example of this technique appears in the movie "12 Angry Men."

In cases, where you do not want the client browser to break text, you should use a nonbreaking space entity &nbsp; instead of a normal space. For example, when coding the "12 Angry Men" in a paragraph, you should use something similar to the following code −

Example

 
<!DOCTYPE html>
<html>
<head>
   <title>Nonbreaking Spaces Example</title>
</head>
<body>
   <p>An example of this technique appears in the movie "12 Angry Men."</p>
   <p>An example of this technique appears in the movie "12&nbsp;&nbsp;&nbsp;Angry Men."</p>
</body>
</html>

 On executing the above example, it will display the sentence: An example of this technique appears in the movie "12 Angry Men.", twice. Since we have added 3 " " characters between 12 and men, the second time, you can observe three spaces.

标签:03,use,HTML,Tags,text,Example,tag,example
From: https://www.cnblogs.com/emanlee/p/18186501

相关文章

  • 【pywinauto】Application(backend='uia').connect(process=18080) 怎么应用程序不在
    【日期】2024/5/13【问题】Application(backend='uia').connect(process=18080) 怎么应用程序不在最前面?【分析】可能是应用程序没有获取到焦点?【原因】在 pywinauto 中,当你使用 Application(backend='uia').connect(process=18080) 连接到一个正在运行的应用程序进程......
  • HTML 02 - Editors
    HTML-EditorsTolearnHTMLwewillrecommendyoutouseatexteditorlikeNotepad,becauseaNotepadwillhelpyoutounderstandtherequirementofeachtag,itwillnotsuggestanythingonitsownthatwillbehelpfultounderstandtheHTMLsyntax. ......
  • HTML Tutorial
     HTMLstandsforHyperTextMarkupLanguage,itisaStandardMarkuplanguageforwebpages.HTMLisusedtocreatecontentandstructureofanywebpage.IfyouthinkofthehumanbodyasawebpagethenHTMListheskeletonofthebody.Itisthebuildi......
  • MAC make编译报错 “clang: error: unsupported option '-fopenmp'”
    编译报错➜php_mt_seed-mainmakegcc-Wall-march=native-mtune=generic-O2-fomit-frame-pointer-funroll-loops-fopenmpphp_mt_seed.c-ophp_mt_seedclang:error:unsupportedoption'-fopenmp'clang:error:unsupportedoption'-fopenmp'......
  • 1250 - Table 'd' from one of the SELECTs cannot be used in field list
    1问题描述sql数据库查询接口union后orderby某字段,提示错误“1250-Table'd'fromoneoftheSELECTscannotbeusedinfieldlist“。移除orderby条件,就不会报错,但是不满足按照某个字段排序。 2方案解决修改排序条件为:orderbystatId即可。(union后的结果是字段......
  • OpenAI 或将推出多模态人工智能数字助理;研究发现部分 AI 系统已学会「说谎」丨 RTE 开
      这里是「RTE开发者日报」,每天和大家一起看新闻、聊八卦。我们的社区编辑团队会整理分享RTE(RealTimeEngagement)领域内「有话题的新闻」、「有态度的观点」、「有意思的数据」、「有思考的文章」、「有看点的会议」,但内容仅代表编辑的个人观点,欢迎大家留言......
  • 野火指南者STM32F103+STM32CubeMX FSMC实现LCD屏幕显示
    MCU:STM32F103VET6开发环境:STM32CubeMX+MDK5最近针对STM32的LCD进行复习,顺便展开一下笔记。 STM32LCD液晶屏(ILI9341)本文章使用STM32F103VET6,野火指南者的3.2寸电阻屏,进行学习。 LCD液晶显示针对野火指南者配套资料:3.2寸LCD电阻屏,屏幕里自带ILI9341液晶控制器芯片,......
  • [转帖]IIS 403错误详细原因
    https://www.cnblogs.com/wang_yb/archive/2010/05/10/1732093.html 在使用IIS的时候,如果遇到403相关的错误,往往束手无策,不知道是什么权限的原因。现总结如下,供以后参考。 403.1-执行访问被禁止下面是导致此错误信息的两个常见原因:1、您没有足够的执行许可例如,如......
  • P2340 [USACO03FALL] Cow Exhibition G
    原题链接题解1.考虑到每个牛只有选或不选两种选择,这样暴力搜索的思路便产生了2.还是上面的思路,怎么优化呢?想想背包数组,其下标是什么?是体积其值是是什么?是价值是在体积相同的情况下选择价值最高的,本题也是,最优解一定是相同智商里情商最高的3.价值和体积都是负数,怎么解决?cod......
  • 'sh' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
    我们在windows系统中执行:shnacos-config.sh-h127.0.0.1命令是报错的。报错:'sh'不是内部或外部命令,也不是可运行的程序或批处理文件。但是作为一名软件开发人员,我们的电脑上一般都是安装有git的。这个时候,我们可以使用git执行上面的命令就可以了,因为git是安装有sh命令的。......