DEV Community

Cover image for Html and CSS attributes
antony stark
antony stark

Posted on

Html and CSS attributes

HTML Attributes:-Attributes provide additional information about elements,it usually come in name/value pairs like: name="value"

Some of the attributes are:-

  • Href Attribute:-The a tag defines a hyperlink. The href abbreviation is hyper reference which gives a tag with additional information and helps to redirect another web page

Example

<a href="https://www.google.com">google</a>
Enter fullscreen mode Exit fullscreen mode
  • Src attribute:-The img tag is used to embed an image in an HTML page. The src attribute specifies the path to the image to be displayed:

Example

<img src="img_bike_honda_cbr.jpg">
Enter fullscreen mode Exit fullscreen mode
  • Width and Height attribute:-width and height attributes can specify the width and height of the content and can be used in both html and css

Example

<img src="img_honda_cbr.jpg" width="50" height="60">
Enter fullscreen mode Exit fullscreen mode
  • Alt attribute:-alt attribute for the img tag specifies an alternate text for an image, if the image for some reason cannot be displayed, This can be due to a slow connection, or an error in the src attribute

Example

<img src="img_mazda_787b.jpg" alt="Car thumbnail">
Enter fullscreen mode Exit fullscreen mode
  • Style attribute:-The style attribute gives the entire access to the css properities and act as a inline css to the document,user can modify the size,color,font etc

Example

<p style="color:red;">This is a red </p>
Enter fullscreen mode Exit fullscreen mode
  • Type and Placeholder:- these two attributes are used in the input tag ,usually for specify which type of input is used, like text,email,password,number.

Example

<input type="text" placeholder='Enter your username here'>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)