Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ Control your drop caps with CSS initial-letter

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Control your drop caps with CSS initial-letter


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: developer.chrome.com

The art of styling drop caps has been around for hundreds, if not thousands of years. Its use in print styles to signify the start of a new section or chapter can be seen through history. But, it's always been problematic to style in the digital age. There hasn't been a "clean" solution to styling them.

The CSS initial-letter property will make things much easier.

Browser support

Where can you try initial-letter? It's available in Safari and from Chrome 110. There is an open issue for it to be implemented in Firefox.

There is also an open Chromium issue detailing the related properties initial-letter-align and initial-letter-wrap that are still to be implemented as per the CSSWG spec.

Test for initial-letter support with:

@supports (initial-letter: 1 1) { /* Your supported styles */ }

Current solutions

How might you style a drop cap in CSS today?

The :first-letter pseudo-class gets us part of the way.

p:first-letter {
color: hsl(220, 94%, 51%);
font-weight: bold;
font-size: 4rem;
}

But then you likely need to reach for properties like "float" whilst calculating a size for that first letter.

p:first-letter {
color: hsl(220, 94%, 51%);
font-weight: bold;
font-size: 4rem;
float: left;
line-height: 1;
margin-right: 0.25rem;
}

The introduction of new CSS units like lh could ease some of this pain. But, these have limited support too (lh is currently only supported in Chrome).

p:first-letter {
color: hsl(220, 94%, 51%);
font-weight: bold;
font-size: 3lh;
float: left;
line-height: 1;
margin-right: 0.1lh;
}

Introducing initial-letter

The initial-letter property gives you finer control over this drop cap styling. It takes two space separated values:

p:first-letter {
initial-letter: 3.5 3;
}
  • The first argument defines the size of the letter and how many lines it will occupy. The letter will scale up whilst maintaining its aspect ratio.You canโ€™t use a negative value but you can use decimal values.
  • The second argument defines the letter sink. This can be thought of as the offset for where the letter will sit. The second value is optional and canโ€™t be negative. If it isnโ€™t present, it assumes the value for the letter size floored to the nearest integer. This is equivalent to using the keyword โ€œdropโ€. The sink also accepts another keyword value, โ€œraiseโ€ which is equivalent to a sink of 1.

Check out this demo where you can change the values to see how it affects the drop cap styling.

Combine it with :first-line and you could have something like this

p:first-line {
font-variant: small-caps;
font-weight: bold;
font-size: 1.25rem;
}
p:first-letter {
font-family: "Merriweather", serif;
initial-letter: 3.5 3;
font-weight: bold;
line-height: 1;
margin-right: 1rem;
color: #3b5bdb;
text-shadow: 0.25rem 0.25rem #be4bdb;
}

Or perhaps, give it a border. Note how the following example uses the โ€œdropโ€ keyword which would be the default if omitted and equates to 3:

p:first-letter {
font-family: "Merriweather", serif;
initial-letter: 3.5 drop;
font-weight: bold;
line-height: 1;
margin-right: 1rem;
color: #3b5bdb;
border: 0.25rem dashed #be4bdb;
padding: 0.5rem;
border-radius: 5px;
}

Maybe add a background or some box-shadow:

p:first-letter {
font-family: "Merriweather", serif;
initial-letter: 3.5 3;
font-weight: bold;
line-height: 1;
margin-right: 1rem;
color: var(--surface-1);
background: #be4bdb;
padding: 0.5rem;
border-radius: 5px;
box-shadow: 0.5rem 0.5rem 0 #3b5bdb;
}

Or clip the background to the text:

p:first-letter {
background: linear-gradient(to bottom right,#1f005c,#5b0060,#870160,#ac255e,#ca485c,#e16b5c,#f39060,#ffb56b);
font-family: "Merriweather", serif;
initial-letter: 3.5 3;
font-weight: bold;
line-height: 1;
margin-right: 1rem;
color: transparent;
-webkit-background-clip: text;
padding: 0.5rem;
}

Youโ€™ve got a lot of possibilities!

And there you have it, finer control over your drop cap styling with initial-letter! Would you add drop caps to your typography? How might you style them? Let us know!

...



๐Ÿ“Œ CAPS Wizard 5.3 - Caps Lock, Shift, Function (fn), Control, Option, or Command on-screen indicators.


๐Ÿ“ˆ 41.63 Punkte

๐Ÿ“Œ CSS Grid: Moving From CSS Frameworks To CSS Grid (2018 and beyond)


๐Ÿ“ˆ 28.81 Punkte

๐Ÿ“Œ Stylify CSS: Automagic CSS bundles splitting into CSS layers in Astro.build


๐Ÿ“ˆ 28.81 Punkte

๐Ÿ“Œ A BRIEF REVIEW OF CSS CASCADING, CSS SELECTORS and CSS SPECIFICITY.


๐Ÿ“ˆ 28.81 Punkte

๐Ÿ“Œ Your 4K Netflix Streaming Is On a Collision Course With Your ISP's Data Caps


๐Ÿ“ˆ 25.07 Punkte

๐Ÿ“Œ Remap Caps-Lock (to Escape, Control, etc.) Persistently


๐Ÿ“ˆ 23.55 Punkte

๐Ÿ“Œ Stylify CSS: Code your Remix website faster with CSS-like utilities


๐Ÿ“ˆ 22.7 Punkte

๐Ÿ“Œ Stylify CSS: Code your SvelteKit website faster with CSS-like utilities


๐Ÿ“ˆ 22.7 Punkte

๐Ÿ“Œ Stylify CSS: Code your Laravel website faster with CSS-like utilities


๐Ÿ“ˆ 22.7 Punkte

๐Ÿ“Œ Transform Your CSS Game: Bookmark These 10 CSS Generators


๐Ÿ“ˆ 22.7 Punkte

๐Ÿ“Œ If you've got one of these Fallout Xbox controllers stashed in your vault, it could be worth a lot of caps


๐Ÿ“ˆ 21.57 Punkte

๐Ÿ“Œ Customize your mechanical keyboard with these 37 rainbow key caps under $17


๐Ÿ“ˆ 21.57 Punkte

๐Ÿ“Œ Drag and Drop Components with basic CSS & Javascript


๐Ÿ“ˆ 19.61 Punkte

๐Ÿ“Œ CSS: How About Building A Search Engine With CSS?


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ mTheme-Unus Theme up to 2.2 on WordPress css/css.php files directory traversal


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Post-Modern CSS (In-Depth on CSS Grid, Flexbox and Other New Properties)


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Medium CVE-2021-33587: Css-what project Css-what


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ State Of CSS Survey: Influence The Future Of CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Do CSS framework users actually know CSS? We might have some data


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ CSS Guide: Basics of CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ How to create navigation menu with HTML CSS step by step | web design tutorial | HTML CSS tutorial


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Learn CSS by Building the Figma Logo in Pure CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Learn CSS by Building the YouTube Logo in Pure CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Learn CSS by Building the Microsoft Logo 2 Different Ways in Pure CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Learn CSS by Building the React Logo in Pure CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Learn CSS by Building the Nextflix Logo in Pure CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Learn CSS by Building the Git Logo in Pure CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Learn CSS by Building the Google Logo in Pure CSS


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ How to Override the Properties of a CSS Class Using Another CSS Class


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ MediaWiki bis 1.23.14/1.26.3/1.27.0 CSS User Subpage Preview common.css Cross Site Scripting


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ The Future of CSS: CSS Houdini


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ New in Chrome 65: CSS Paint API, Server Timing API, and CSS display: contents


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ MediaWiki up to 1.23.14/1.26.3/1.27.0 CSS User Subpage Preview common.css cross site scripting


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Schneider Electric U.motion Builder up to 1.3.3 css.inc.php css directory traversal


๐Ÿ“ˆ 19.21 Punkte

๐Ÿ“Œ Schneider Electric U.motion Builder bis 1.3.3 css.inc.php css Directory Traversal


๐Ÿ“ˆ 19.21 Punkte











matomo