如何在HTML中設定文字刪除的日期和時間?


在使用HTML建立網頁內容時,通常需要更改文字並刪除舊的或錯誤的資訊。保持內容最新非常重要,同時記錄更改的時間也很重要。在HTML中,設定文字刪除的日期和時間是一個簡單的過程。

語法

<del datetime=” ”>content…. </del>

這裡是在``元素中使用的`datetime`屬性,它指定文字刪除的日期和時間。

在HTML中使用``元素

我們使用<del>標籤在HTML中刪除文字。此標籤會在要從文件中刪除的文字上新增刪除線。例如:

<p>We are using <del   datetime="2011-01-05T08:15:30-05:00">CSS</del>    <ins   datetime="2011-01-05T08:15:30-05:00">CSS 3</ins> for web development.</p>

在這裡,我們在``元素中設定了“datetime”屬性,它指定文字刪除時間的內容。

示例

以下是如何使用HTML設定文字刪除日期和時間的示例。

<!DOCTYPE html>
<html>
<head>
   <style>
      body{
         text-align: center;
      }
   </style>
</head>
<body>
   <h3>This is an example of how to use the del element to<br> specify the date and time when the text was deleted</h3>
   <p>We are using <del   datetime="2011-01-05T08:15:30-05:00">CSS</del>    <ins   datetime="2011-01-05T08:15:30-05:00">CSS 3</ins> for web development.</p>
</body>
</html>

在HTML中使用`

在HTML中,`

<p>This text will be deleted : <time datetime="2023-03-25T09:00:00Z">March 25, 2023 at 9:00am UTC</time></p>

在這裡,“此文字將被刪除:”文字後面跟著`

示例

以下是如何使用`

<!DOCTYPE html>
<html>
<head>
   <style>
      body{
         text-align: center;
      }
   </style>
</head>
<body>
   <h3>This is an example of how to use the Time element to<br> add a timestamp for deleted text</h3>
   <p>This text will be deleted: <time datetime="2023-03-25T09:00:00Z">March 25, 2023 at 9:00am UTC</time></p>
</body>
</html>

結論

在這裡,我們討論瞭如何在HTML中設定文字刪除的日期和時間。在HTML中,透過使用``元素和`

更新於:2023年4月12日

124 次瀏覽

啟動你的職業生涯

完成課程獲得認證

開始學習
廣告