In the previous article, I have explained everything about Look Up column type in SharePoint lists. We have seen the different behavior of the column in Lists. Now, in this article, I will be explaining Hyperlink or Picture Column type in detail and will also cover the following topics in detail.
- Introduction to Hyperlink or Picture columns in SharePoint
- Behavior of column as Hyperlink
- Behavior of column as Picture type
- Why should you not use Single line of text for storing link?
Consider a scenario where you have to save the link of documents and pictures related to data along with the other data. For saving a link you can definitely use Single Line of Text column. While storing the link in Single Line of text column type, the data will look like as shown in the below figure.
Here, you can see that it is a single line of text column but is still showing the data as a link. This link is clickable also. For storing links or pictures, SharePoint also provides a special column type called as Hyperlink or Picture. So what is the difference between storing link in single line of text and in Hyperlink column? Let’s explore the basic differences in this article.
Introduction to Hyperlink or Picture columns in SharePoint
Hyperlink or Picture column allows the user to store the links or picture data. For creating the Hyperlink or Picture column type, you can refer to creating a column in SharePoint list. While creating the column, you have to select the option “Hyperlink or Picture” as shown in the below figure.
While user selects the Hyperlink or Picture, you will have the following property to configure.
Format URL as
This property has only 2 values – Hyperlink and Pictures. If you want this column to save the hyperlink values, then select Hyperlink. And if you want to save the data as a picture, then use Picture.
The behavior of the column as Hyperlink
When you select the Format URL as type as Hyperlink, then while entering the data, you will have the following fields.
Suppose you have entered https://www.google.com value, then the value will be displayed as –
The link is clickable. Clicking on the link will redirect to the given URL. The data will be rendered as a web link.
Behavior of the column as Picture
Sometimes, you want to store the images related to any data. Then in SQL, you were using blob storage. But in SharePoint, you can use this Hyperlink or Picture column to maintain your images also. There is a trick of inserting the picture in SharePoint. In Hyperlink or Picture column, you can only store the link of the image. So you either to have a live link for image or you must upload the image to SharePoint and take the URL from the SharePoint site and save it to the column.
For storing picture, you have to select Format URL type as Picture.
If you have selected the type as Picture and then you try to insert the data in the form, you will get the following interface.
Here, you will notice that there is no difference in both the forms whether it is Hyperlink or it is Picture. The only difference will be in Display. When you use Hyperlink format, then in that case, while rendering the data, it uses anchor tag (<a></a>). When you use Picture format, while rendering the data, it will use Image tab(<img/>). So the rendering of Picture type will be like below.
So, now it is clear how we can use the Hyperlink or Picture column type in SharePoint with its data input format and display format.
Why should we not use Single line of text for storing links?
As we have seen in the Background section, we can use the Single line of text column in a case when we have to store the link only. By default, the browser renders the link as a clickable link using the anchor tag. Then, you would be thinking why one should use Hyperlink column.
There are 2 major reasons.
First, the Hyperlink column validates the input hyperlink. So if you have written invalid link format, then it will not allow you to store the data. For example, see the below figure.
While in Single line of text column, you have to apply some column validation to apply.
Second, while storing link, most of the times you would don’t like to display the link as data but you would like to display some text and the text should be clickable with some predefined hyperlink. For example, This is a hyperlink. Here the link is different and the text is different. This is not possible in Single line of text column type.
While if you are using Hyperlink column type, there you have the option to enter the description and link separately. See the below example.
Once you save these values, the values will be rendered.
Here, you can see that the link is now displayed as C-SharpCorner. Clicking on the text will redirect you to https://www.c-sharpcorner.com.
So these are a few basic reasons why we should not prefer to use Single line of Text to store the links; instead, we should use Hyperlink column of SharePoint.
In this article, we have seen most of the details regarding Hyperlink or Picture column types. We have also compared the single line of text with Hyperlink column types. Along with this, we have also seen how Picture and Hyperlink columns behave.
In my next article, I will explain everything about Calculated column type available in SharePoint.
Any question or feedback or suggestion, please do comment and let me know.