The many ways to link shapes using HTML and CSS
source link: https://www.tuicool.com/articles/F3Ynma7
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
:bulb: Tip of the Week
supported by
Styling links with CSS selectors
CSS selectors offer a powerful way to add style, and contextual information, to HTML elements, and while you can target element IDs, classes, etc.the spec hash been fleshed out over the years to support lots of other things you can easily select to style.
John Rhea highlights the wide variety in which they can be used in this excellent article , but for today we're just going to look at how they can be utilised for links .
Let's say you want to style links to PDF documents, signifying to the user that the link is to a 'document', rather than a Web page. This can beachieved like so:
a[href$=".pdf"] {
background: url('https://i.imgur.com/n8EHrrI.png')
0 50% no-repeat;
padding-left: 20px;
}
The $=
operator in the attribute selector targets the end of the attribute value, looking specifically for links to PDFs. It will then add the linked PDF icon before the full link, like so:
This is just one quick example of how this can be used. You could also use this technique to style links tocertain sites, style internal links differently to those that are outbound, or even to style certain images by targeting the src
attribute of a file. It's worth playing around and experimenting!
This Tip of the Week is sponsored byFlatiron School, where you can learnsoftware engineering,data science, orUX/UI design in just 15 weeks online or on campus.
Recommend
-
37
Different website designs often call for a shape other than a square or rectangle to respond to a click event. Perhaps your site has some kind of tilted or curved banner where the click area would be awkwardly lar...
-
6
[Meme] How Many HTML Elements Can You Name in 5 Minutes? 59
-
9
Many popular HTML rewriters break protocol-relative URLs If you're going to rewrite my HTML, you might as well do it correctly. A fair amount of traffic has been heading this way as a result of
-
5
Have you ever clicked a link on a website, and it’s opened on a new tab in the browser? If you’ve been wondering how you can do that with your links, this article will act as your guide. Prerequisites To follow and co...
-
9
Oftentimes, we get asked to create different custom views and shapes in Android Development. In the old view-based system, we heavily relied on Canvas to create a shape. Luckily, Jetpack Compose introduces new out-of-the-box ways to easily cr...
-
6
React use one Component to many HTML Fragments 198 views 7 months ago React A react component is used to return multi...
-
4
August 12, 2022 ...
-
8
Using a parfor Loop to Store the HTML of Many Web Pages » Stuart’s MATLAB Videos Previously, I used a parfor loop to make a
-
9
Best Ways to Preload Images Using JavaScript, CSS and HTML Monty Shokeen Last updated Jan 30, 2023...
-
2
The curious ways your skin shapes your health Weathered or unhealthy skin is emerging as a major risk factor for almost every single age-related disease, from Parkinson's to type 2 diabetes....
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK