Html attribute values

hello there i just started coding and i cant understand if the value of an attribute is something you have to come up with or it’s standar words. thank you in advance!

  • All HTML elements can have attributes
  • The href attribute of <a> specifies the URL of the page the link goes to
  • The src attribute of <img> specifies the path to the image to be displayed
  • The width and height attributes of <img> provide size information for images
  • The alt attribute of <img> provides an alternate text for an image
  • The style attribute is used to add styles to an element, such as color, font, size, and more
  • The lang attribute of the <html> tag declares the language of the Web page
  • The title attribute defines some extra information about an element

yes but whatabout a <div> or a<p> tag when you want to be more specific?

Yes you can.

<h2 title="I'm a header">The title Attribute</h2>

div >> class
p>> title

could I just put something irrelevant like “dog”?

It depends on the attribute. If you are using the title attribute then sure. Or an alt attribute. If you are using the href then no.

ok, so i used this on a tutorial but i dont get it. <a href="#" class="btn btn-ghost">Sign up now</a>. why use twice the btn and then write ghost?

So when it comes to classes you can create your own class names. You can also can group classes together but for id’s you can’t.

btn is often used as a class to style a button. btn-ghost is popular for “ghost buttons” .

Here is a great article going more in depth about ghost buttons.

At the end of the day you can name your classes whatever. The use of btn is more about popular convention than required if that makes sense.

thank you very much!!!

1 Like