What is html?
html(hyper text markup language) it is a standard language its used to create a structure of web page content.
What is Html Tags?
HTML tags are special keywords enclosed within angle brackets(<>).They tell the browser how to display content. there is lots of tag in html.
example:
<h1>welcome</h1>
what is Html attributes?
while html tage define the sturcture of web pages the attribues are add more information to the tag elements.
Why attributes are important?
- Create hyperlinks
- Display images
- Add styles
- Identify elements
- Improve accessibility
- Build forms
- Add metadata
Types of Html attributes
- href
- target
- src
- alt
- width
- height
- type
- placeholder
- required
- action
- method
- id
- class
- style
- title
- hidden
- lang
- dir
Common Html Attributes?
- id Attribute
The id attribute uniquely identifies an HTML element.Each id value should be unique within a webpage.
<div id="header">
Welcome!
</div>
- class Attribute
The class attribute groups elements together. It is mainly used with CSS and JavaScript.Multiple elements can share the same class
<p class="highlight">
This is important.
</p>
3.** href Attribute**
The href attribute specifies the destination of a hyperlink.Without href, the link won't navigate anywhere.
<a href="https://www.google.com">
Google
</a>
4.** src Attribute**
The src attribute specifies the location of an image, video, audio, or other external resource.
<img src="nature.jpg" alt="Nature">
- alt Attribute
The alt attribute provides alternative text if an image cannot be displayed. It also improves accessibility for screen readers.Always provide meaningful alt text.
<img src="cat.jpg" alt="A cute orange cat">
- style Attribute
The style attribute allows you to apply inline CSS directly to an element.For larger projects, prefer external CSS over inline styles.
<p style="color: blue; font-size: 20px;">
Hello Friends!
</p>
- target Attribute
The target attribute specifies where a linked document should open.
Common values:
_self
_blank
_parent
_top
- placeholder Attribute
Displays hint text inside input fields.
<input
type="text"
placeholder="Enter your name">
- required Attribute
Makes an input field mandatory.Users must enter a value before submitting the form.
<input
type="email"
required>
- disabled Attribute
Disables an element.Disabled elements cannot be interacted with.
<button disabled>
Submit
</button>
- value Attribute
Specifies the initial value of an input element.
<input
type="text"
value="John">
- width and height Attributes
Set the dimensions of images.
<img
src="mountain.jpg"
width="400"
height="250"
alt="Mountain">
- maxlength Attribute
Limits the number of characters a user can type.
<input
type="text"
maxlength="20">
- readonly Attribute
Makes an input field read-only.Users can see the value but cannot edit it.
<input
type="text"
value="Admin"
readonly>
*Combining multiple Attributes *
An one elements have multiple attributes. this is very common in real world projects.
<input type="text" id="username" class="form-control" placeholder=" Enter your username" required>
Conculution
As you continue learning HTML, practice using different attributes together in small projects. The more you experiment, the more comfortable you'll become with writing clean and effective HTML.
Happy Coding!
Top comments (0)