What is an attribute?
For example, eye color is an attribute of a person, while screen size is an attribute of a smartphone or TV. In computing and computer programming, an attribute is a changeable property or characteristic of some component of a program that can be set to different values.
What are attributes in computing?
In computing, the term attribute is used in many different contexts. In the context of a file system, it refers to a characteristic of a file in that system. So, a particular file can have a read-only attribute, which means it is write protected and can't be changed. Another file may not have this attribute, so a person or an application can both read and write to it.
Similarly, in an HTML tag used in building a web page, an attribute specifies certain aspects of an element on a page and could have a specific value.
An attribute defines a particular property of an object, element or file. It can also refer to a specific value for a given instance of that property. In most cases, a property owner would own these property attributes. All attributes are associated with a set of operations that determine what is and isn't possible to do with that attribute and the object, element or file it defines.
What are attributes in HTML?
In markup languages like Hypertext Markup Language (HTML) and Extensible Markup Language (XML), attributes describe data and data formatting. Thus, an attribute is usually a characteristic of an HTML page element, such as font color.
While programming in HTML, a user can set font attributes, such as size and color, to different values. Thus, p style="color:red" sets the paragraph attribute to red so the text will display in red. Similarly, they can set other attributes, such as font size, image path and web page language.
In short, different attributes provide additional information about HTML elements. They're usually written in the form of a name/value pair with the syntax name="value".
The most common attributes in HTML are:
<a href="https://www.techtarget.com/whatis/definition/attribute">What is attribute?</a>
The src attribute specifies the path/source of an image being displayed. It's accompanied by the <img> tag. The URL can be specified in two ways using the src attribute: absolute URL and relative URL.
The absolute URL links to an external image on a third-party website.
<img src ="https://www.externalwebsite.com/images/img_phone.jpg ">
A relative URL links to an image hosted within the same website.
<img src =”img_phone.jpg ">
While both are valid, it's usually better to use relative URLs because the image won't break if the domain is changed. An absolute URL depends on an external website, so if its domain changes or goes down, the image will break and affect user experience (UX).
3. Width and Height
These attributes specify the width and height of the image in pixels. They're also used with the <img> tag.
<img src ="img_phone.jpg " width="260” height="480">
The alt attribute specifies an alternate text for an image. This text tells the user what the image is about. It's indexed by search engines and also read aloud by screen reader software such as that used by visually impaired users. The alt attribute is especially important if the image is missing or broken, and is important from both an SEO and UX perspective.
<img src ="img_phone.jpg " alt="Android smartphone with stylus"">
The style attribute is used to add different styles to an HTML element, such as color, font or size.
<p style="color:purple;"> This is a purple paragraph.</p>
The lang attribute, which is always included inside the <html> tag, declares the language of the web page to help search engines and browsers. A country code can be added to the language code if there are many country-level variants of a language. English is one such language.
<html lang="en"> for the US
<html lang="en-UK"> the United Kingdom
The title attribute adds extra information about an HTML element. Its value is displayed as a tooltip when a user mouses over that element.
<p title="I am a tooltip"> This is a paragraph.</p>
What is an attribute in a database management system?
In a database management system (DBMS), an attribute may describe the characteristics or properties of a component or entity, such as a database table or a field. If the database is compared to a spreadsheet, the attribute is simply one -- non-null -- cell or the conjunction of a particular column and row.
An entity in a DBMS may contain any number of attributes. If a row in the database contains invoice entries, attributes for these entries could include invoice number, date created, data paid and value. If the row contains student details, attributes could include name, date of birth or age, gender, address, roll number and phone number.
There are different types of attributes in a DBMS. These include:
Simple attributes are independent and can't be classified further or subdivided into other components. They are also known atomic attributes.
An example of a simple attribute is the age of a person.
Composite attributes can be subdivided into different components or subparts. One or more simple attributes form composite attributes.
A common example of a composite attribute is the address of a person, which can be composed of their street name, city name, ZIP code and country.
Single-valued attributes contain a single value for each entity instance. These values remain constant and can't be subdivided into other attributes.
Date of birth, age and gender are all examples of single-valued attributes.
Unlike single-valued attributes, multivalued attributes can store more than one value at a time from a set of possible values.
Email address and phone number are two examples, since a person can have more than one email address and phone number.
Derived attributes draw their values from other attributes. One example is the age attribute that's derived from the date of birth attribute.
Key attributes can uniquely identify an entity from a set. These attributes always have non-repeating values. An example is a person's social security number, which is unique to an individual.
Complex attributes are formed by combining multivalued and composite attributes. They usually have many subsections and are rarely used in DBMS.
For example, an attribute called "addr_emph" represents a person's physical address, email address and phone number. The address is a composite attribute, while the phone number and email address are multivalued attributes. Combining them creates the complex attribute.
Stored attributes have fixed values for an entity. They also help to set derived attributes. For example, age is a derived attribute of date of birth, while date of birth is a stored attribute of age.
What are attributes in DOS?
The attrib command is used to display or change file attributes. The most common options are:
|Options (with attrib)||Action|
Sets an attribute
File is read-only
Clears an attribute
Learn about relational databases, how to create an HTML5 and PHP file upload form for Apache and explore the difference between functional and object-oriented programming.