国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
,
Home Web Front-end CSS Tutorial Introduction to HTML Elements

Introduction to HTML Elements

Jan 14, 2025 am 06:47 AM

In this lesson, we are going to explore the different HTML tags, their purposes, and how to use them effectively in your web applications. We will discuss some of the most commonly used HTML tags and their corresponding attributes.

The paragraph tag

The paragraph is probably the most commonly used HTML element, which is defined by

. It is a block-level element, meaning each paragraph will start on a new line.
  <p>This is the first paragraph.</p>
  <p>This is the second paragraph, which starts on a new line.</p>

Without the

element, your browser will automatically ignore the extra white spaces and render the text in a single line.

<!-- prettier-ignore -->

  This is the first paragraph.
  This is the second paragraph, which starts on a new line.

Visit Code Demo ↗

You'll need to use the
element if you want a line break inside a single paragraph element. This is one of those HTML elements that does not require a closing tag.

  <p>
    This is the first paragraph.<br>
    This is the second paragraph, which starts on a new line.
  </p>

Visit Code Demo ↗

The heading tags

When writing an article, it is good to add headings between paragraphs to make the article more organized. An HTML document works the same way. HTML offers six different levels of headings from

to

.
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Visit Code Demo ↗

In most cases,

to

should be sufficient when creating webpages, and generally, we recommend not using headings that are too small, such as

and
, as they would make the structure of your webpage unnecessarily complex.

is the top heading, and it plays a special role in the webpage. There should only be one

element in each HTML document, and it should summarize the entire page.

Formatting elements

Sometimes, you may want to emphasize specific words and paragraphs by giving them different formats, such as making them appear bold, italic, or underlined. HTML provides formatting elements that can help achieve this effect.

<b></b>
<strong></strong>

<i></i>
<em></em>

<mark></mark>

<small></small>

<del></del>
<ins></ins>

<sub></sub>
<sup></sup>

Visit Code Demo ↗

  • The and elements have the same effect. They both make the enclosed text appear bold.
<p>
  Lorem ipsum <b>dolor sit</b> amet consectetur
  <strong>adipisicing elit</strong>.
</p>

Even though they have the same appearance, as shown in the CodePen demo, they serve different purposes for browsers and search engines.

only makes the text bold without adding any particular meaning, while indicates the enclosed texts have substantial importance.

  • The and elements are similar. They both turn the text into italic form. does not indicate any special meaning, while defines an emphasized text, displayed in italic form.
  <p>This is the first paragraph.</p>
  <p>This is the second paragraph, which starts on a new line.</p>

  • The element defines highlighted/marked texts.
<!-- prettier-ignore -->

  This is the first paragraph.
  This is the second paragraph, which starts on a new line.

  • The element defines small text.
  <p>
    This is the first paragraph.<br>
    This is the second paragraph, which starts on a new line.
  </p>

  • The element indicates deleted text, displayed by adding strikethrough across the enclosed text. On the other hand, the element is used to indicate inserted text, which is displayed as underlined text.
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
  • The and elements defines subscript and superscript respectively.
<b></b>
<strong></strong>

<i></i>
<em></em>

<mark></mark>

<small></small>

<del></del>
<ins></ins>

<sub></sub>
<sup></sup>

How to add styles to HTML elements

Sometimes, the default representations of these formatting elements are inadequate to express their intended meanings.

For example, the element indicates deleted texts with a strikethrough, which is easy to understand. However, the element uses underline to represent insertions, which can be very confusing.

To improve the default appearance of these elements, you can use a style attribute like this:

<p>
  Lorem ipsum <b>dolor sit</b> amet consectetur
  <strong>adipisicing elit</strong>.
</p>

By default, the Introduction to HTML Elements will be underlined and displayed in blue, and when you click on it, you will be taken to the Introduction to HTML Elements specified by the href attribute.

To demonstrate, create a Introduction to HTML Elements.html file in your work directory.

<p>Lorem ipsum <i>dolor sit</i> amet consectetur <em>adipisicing elit</em>.</p>
<p>Lorem ipsum <mark>dolor sit</mark> amet consectetur adipisicing elit.</p>

And then, add a Introduction to HTML Elements in your index.html file that points to the Introduction to HTML Elements.

<p>Lorem ipsum <small>dolor sit</small> amet consectetur adipisicing elit.</p>

Introduction to HTML Elements

You will be taken to the Introduction to HTML Elements.html document when you click on the Introduction to HTML Elements.

Introduction to HTML Elements

You can also add a Go Back Introduction to HTML Elements in the Introduction to HTML Elements.html to take you back to index.html.

<p>
  Lorem ipsum <del>dolor sit</del> amet <ins>consectetur adipisicing</ins> elit.
</p>

go back Introduction to HTML Elements

These interconnected Introduction to HTML Elementss form the internet we see today.

By default, the Introduction to HTML Elementsed Introduction to HTML Elements will be opened in the same window. You can change that behavior by setting a target attribute. For example, target="_blank" opens the Introduction to HTML Elements in a new tab.

<p>
  Lorem ipsum <sub>dolor sit</sub> amet <sup>consectetur adipisicing</sup> elit.
</p>

Visit Code Demo ↗

Another thing you may have noticed is that the Introduction to HTML Elements is initially displayed in blue. The moment you click on it, it turns red. Afterward, the Introduction to HTML Elements becomes purple, indicating that the Introduction to HTML Elements has been visited before.

This behavior has to do with a concept called the pseudo-class, which allows you to define different styles for an element under different conditions. We will revisit this topic when we talk more about CSS.

Lists

Visit Code Demo ↗

There are three different types of lists in HTML: ordered, unordered, and description lists.

Ordered lists are defined with the

    element, and each individual list item is created with
  1. .
      <p>This is the first paragraph.</p>
      <p>This is the second paragraph, which starts on a new line.</p>
    
    

    Unordered lists are defined with the

      element.
    <!-- prettier-ignore -->
    
      This is the first paragraph.
      This is the second paragraph, which starts on a new line.
    
    

    Description lists are a bit more complex, as they consist of a list of items and a description for each item. The description list is defined with the

    element, each list item is defined with
    , and each description statement is defined with
    .
      <p>
        This is the first paragraph.<br>
        This is the second paragraph, which starts on a new line.
      </p>
    
    

    Layout elements

    So far, we've only been discussing elements used to display content, such as texts, lists, and images. In fact, there is another category of elements in HTML in charge of organizing these elements.

    They are not designed to display any specific type of content, but instead, they act as a container for other elements. When combined with CSS, they can create different layouts for the webpage. Some of the commonly used layout elements are shown in the list below.

    • : Defines a header section for the document, usually located at the top of the webpage.
    • : Defines a section for the document.
    • : Defines an independent section in the webpage.
    • : A footer section located at the bottom of the webpage.
    • : Creates a tab that the user can open and close.
    • : Creates a heading for the
      element. It should be placed inside the
      element.
    <h1>Heading 1</h1>
    <h2>Heading 2</h2>
    <h3>Heading 3</h3>
    <h4>Heading 4</h4>
    <h5>Heading 5</h5>
    <h6>Heading 6</h6>
    

    Visit Code Demo ↗

    • : And, of course, the most important layout element,
      , which stands for division. It is a generic element that creates a block in the webpage and does not serve any special purposes.

      This is the most commonly used layout element, because for real-life webpages, most sections and blocks do not match any of the semantic elements mentioned above. As a result, many developers like to use

      for creating page layouts.
        <p>This is the first paragraph.</p>
        <p>This is the second paragraph, which starts on a new line.</p>
      
      

      p vs a

      Notice that the

      element always starts on a new line and takes up as much horizontal space as possible. On the other hand, the element does not start on a new line and only takes up as much space as necessary.

      This is, in fact, the difference between the block elements and inline elements.

      Most of the elements we mentioned so far are block elements, such as

      ,

      ,

      to

      ,
    • , etc. Without extra styles defined, they will automatically take up as much horizontal space as possible.

      The element is an example of an inline element. It only takes up as much space as necessary when placed along side other elements. And the width and height attributes will have no effects on it.

      There are many other elements, both block and inline elements available in HTML. It is impossible to discuss all of them in one lesson, but here is a reference of all HTML elements from W3Schools if you are interested.

      Further readings

      • How to Use CSS Selectors
      • What are the Semantic HTML Code?
      • How to Center A Div in CSS

The above is the detailed content of Introduction to HTML Elements. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is 'render-blocking CSS'? What is 'render-blocking CSS'? Jun 24, 2025 am 12:42 AM

CSS blocks page rendering because browsers view inline and external CSS as key resources by default, especially with imported stylesheets, header large amounts of inline CSS, and unoptimized media query styles. 1. Extract critical CSS and embed it into HTML; 2. Delay loading non-critical CSS through JavaScript; 3. Use media attributes to optimize loading such as print styles; 4. Compress and merge CSS to reduce requests. It is recommended to use tools to extract key CSS, combine rel="preload" asynchronous loading, and use media delayed loading reasonably to avoid excessive splitting and complex script control.

External vs. Internal CSS: What's the Best Approach? External vs. Internal CSS: What's the Best Approach? Jun 20, 2025 am 12:45 AM

ThebestapproachforCSSdependsontheproject'sspecificneeds.Forlargerprojects,externalCSSisbetterduetomaintainabilityandreusability;forsmallerprojectsorsingle-pageapplications,internalCSSmightbemoresuitable.It'scrucialtobalanceprojectsize,performanceneed

Does my CSS must be on lower case? Does my CSS must be on lower case? Jun 19, 2025 am 12:29 AM

No,CSSdoesnothavetobeinlowercase.However,usinglowercaseisrecommendedfor:1)Consistencyandreadability,2)Avoidingerrorsinrelatedtechnologies,3)Potentialperformancebenefits,and4)Improvedcollaborationwithinteams.

CSS Case Sensitivity: Understanding What Matters CSS Case Sensitivity: Understanding What Matters Jun 20, 2025 am 12:09 AM

CSSismostlycase-insensitive,butURLsandfontfamilynamesarecase-sensitive.1)Propertiesandvalueslikecolor:red;arenotcase-sensitive.2)URLsmustmatchtheserver'scase,e.g.,/images/Logo.png.3)Fontfamilynameslike'OpenSans'mustbeexact.

What is Autoprefixer and how does it work? What is Autoprefixer and how does it work? Jul 02, 2025 am 01:15 AM

Autoprefixer is a tool that automatically adds vendor prefixes to CSS attributes based on the target browser scope. 1. It solves the problem of manually maintaining prefixes with errors; 2. Work through the PostCSS plug-in form, parse CSS, analyze attributes that need to be prefixed, and generate code according to configuration; 3. The usage steps include installing plug-ins, setting browserslist, and enabling them in the build process; 4. Notes include not manually adding prefixes, keeping configuration updates, prefixes not all attributes, and it is recommended to use them with the preprocessor.

What are CSS counters? What are CSS counters? Jun 19, 2025 am 12:34 AM

CSScounterscanautomaticallynumbersectionsandlists.1)Usecounter-resettoinitialize,counter-incrementtoincrease,andcounter()orcounters()todisplayvalues.2)CombinewithJavaScriptfordynamiccontenttoensureaccurateupdates.

CSS: When Does Case Matter (and When Doesn't)? CSS: When Does Case Matter (and When Doesn't)? Jun 19, 2025 am 12:27 AM

In CSS, selector and attribute names are case-sensitive, while values, named colors, URLs, and custom attributes are case-sensitive. 1. The selector and attribute names are case-insensitive, such as background-color and background-Color are the same. 2. The hexadecimal color in the value is case-sensitive, but the named color is case-sensitive, such as red and Red is invalid. 3. URLs are case sensitive and may cause file loading problems. 4. Custom properties (variables) are case sensitive, and you need to pay attention to the consistency of case when using them.

What is the conic-gradient() function? What is the conic-gradient() function? Jul 01, 2025 am 01:16 AM

Theconic-gradient()functioninCSScreatescirculargradientsthatrotatecolorstopsaroundacentralpoint.1.Itisidealforpiecharts,progressindicators,colorwheels,anddecorativebackgrounds.2.Itworksbydefiningcolorstopsatspecificangles,optionallystartingfromadefin

See all articles