Friday, June 21, 2024

All the Attributes of html page with description and uses

All the Attributes of html page with description and uses

Hello guys how are you? Welcome back to my blog. Today in this post we will learn All the Attributes of html page with description and uses.

HTML attributes are special words used inside the opening tag of an HTML element to control the element’s behavior or provide additional information about it. Here’s a list of common HTML attributes with examples:

1. class

Specifies one or more class names for an element, used for CSS styling.

<div class="container main-content"></div>

2. id

Specifies a unique id for an element, used to identify the element and for CSS or JavaScript.

<p id="intro">Welcome to our website!</p>

3. style

Specifies an inline CSS style for an element.

<h1 style="color: blue; text-align: center;">Hello, World!</h1>

4. title

Provides additional information about an element (displayed as a tooltip when the mouse hovers over the element).

<button title="Click to submit">Submit</button>

5. href

Specifies the URL of the page the link goes to (for <a> elements).

<a href="">Visit Example</a>

6. src

Specifies the URL of the image, video, or other resource.

<img src="image.jpg" alt="Description of image">

7. alt

Provides alternative text for an image if it cannot be displayed.

<img src="image.jpg" alt="Description of image">

8. type

Specifies the type of the element (for <input>, <button>, and <script> elements).

<input type="text" placeholder="Enter your name">

9. value

Specifies the initial value of an input element.

<input type="text" value="Default text">

10. name

Specifies the name of an input element, used to reference form data after submission.

<input type="text" name="username">

11. placeholder

Provides a hint that describes the expected value of an input field.

<input type="email" placeholder="Enter your email">

12. disabled

Disables an element, making it unresponsive to user interactions.

<button disabled>Cannot Click</button>

13. readonly

Specifies that an input field is read-only.

<input type="text" value="Read only text" readonly>

14. checked

Specifies that an input element (checkbox or radio button) should be pre-selected.

<input type="checkbox" checked> Remember me

15. target

Specifies where to open the linked document (for <a> elements).

<a href="" target="_blank">Open in new tab</a>

16. data-*

Used to store custom data private to the page or application.

<div data-user-id="12345"></div>

17. lang

Specifies the language of the element’s content.

<p lang="en">This is an English paragraph.</p>

18. maxlength

Specifies the maximum number of characters allowed in an input field.

<input type="text" maxlength="10">

19. min

Specifies the minimum value for an input element.

<input type="number" min="1">

20. max

Specifies the maximum value for an input element.

<input type="number" max="100">

21. step

Specifies the legal number intervals for an input element.

<input type="number" step="5">

22. autofocus

Specifies that an input element should automatically get focus when the page loads.

<input type="text" autofocus>

23. form

Specifies one or more forms the input element belongs to.

<input type="submit" form="form1" value="Submit Form">

24. action

Specifies where to send the form-data when a form is submitted.

<form action="/submit_form" method="post">

25. method

Specifies the HTTP method to use when sending form-data.

<form action="/submit_form" method="post">

26. enctype

Specifies how the form-data should be encoded when submitting.

<form action="/submit_form" method="post" enctype="multipart/form-data">

27. required

Specifies that an input field must be filled out before submitting the form.

<input type="text" required>

28. multiple

Specifies that the user can enter more than one value in an input element.

<input type="file" multiple>

29. accept

Specifies the types of files that the server accepts (for <input type="file">).

<input type="file" accept=".jpg, .jpeg, .png">

30. autocomplete

Specifies whether an input field should have autocomplete on or off.

<input type="text" autocomplete="on">

These are some of the most commonly used HTML attributes, each providing specific functionalities to the elements they are associated with.

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.