HTML
 Computer >> コンピューター >  >> プログラミング >> HTML

HTMLのreadOnly属性


HTML readOnly属性は、input / textarea要素が読み取り専用であることを表します。つまり、HTMLドキュメントのコンテンツを変更することはできません。

構文

以下は構文です-

<tagname readOnly></tagname>

HTMLのreadOnly属性の例を見てみましょう-

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      height: 100vh;
      background-color: #8BC6EC;
      background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
      text-align: center;
   }
   input {
      display: block;
      width: 50%;
      margin: 1rem auto;
      text-align: center;
   }
</style>
<body>
<h1>HTML readOnly Demo</h1>
<input type="text" value="I'm an input element with readOnly property" readOnly>
</body>
</html>

出力

HTMLのreadOnly属性


  1. HTMLラップ属性

    HTML wrap属性は、フォームがHTMLドキュメントで送信されたときにテキスト領域のテキストをどのように折り返すかを定義します。 構文 以下は構文です- <textarea wrap=”hard | soft”></textarea> HTMLラップ属性の例を見てみましょう- 例 <!DOCTYPE html> <html> <style>    body {       color: #000;       height:

  2. HTMLドラッグ可能属性

    HTML DOMドラッグ可能属性は、要素がドラッグ可能かどうかを指定するブール値を返す/設定します。 注 −リンクと画像はデフォルトでドラッグ可能です。 HTMLドラッグ可能の例を見てみましょう 属性- 例 <!DOCTYPE html> <html> <head> <title>HTML DOM draggable</title> <style>    * {       padding: 2px;       margin:5px; &n