SShortSingh.
Back to feed

CSS text-wrap: balance eliminates orphaned words in headlines natively

0
·1 views

Frontend developers have long struggled with orphaned words in headings, where a single word wraps alone onto a new line at certain viewport widths. The CSS property text-wrap: balance offers a native browser-level fix by distributing text as evenly as possible across all lines without requiring manual edits or JavaScript. A companion property, text-wrap: pretty, addresses the same orphan problem in body text by applying a lookahead only on the final few lines, leaving the rest of the paragraph unchanged. Together, both properties replace older workarounds such as non-breaking spaces, soft hyphens, max-width tweaks, and JavaScript rebalancing libraries. The balance property is intentionally limited to roughly six lines of content to keep the underlying algorithm computationally efficient, making it best suited for headlines and pull quotes.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How Modern Applications Use Layered Security to Safeguard User Data

Modern applications protect user data through multiple overlapping security measures rather than relying on any single defence. Core practices include encrypting data in transit and at rest using standards like TLS and AES-256, alongside strong authentication methods such as MFA, passkeys, and biometrics. Developers are also advised to hash passwords with algorithms like Argon2 or bcrypt, validate all user inputs to prevent injection attacks, and apply rate limiting to guard against brute-force and API abuse. Continuous monitoring of suspicious activity, regular software updates, and secure API design further reduce the risk of breaches. Privacy-by-design principles — including data minimisation, user consent management, and defined retention policies — are recommended to be built into application architecture from the outset.

0
ProgrammingDEV Community ·

12 Security Checks Developers Should Apply to Every File Upload Feature

File upload endpoints are among the most exploited attack surfaces in web and mobile applications, capable of enabling malware injection, remote code execution, and server compromise. A DEV Community article outlines 12 critical security measures developers frequently overlook before deploying upload functionality. Key recommendations include server-side MIME type and magic-byte validation, strict allowlists for file types, antivirus scanning, and storing files outside the public web root with authenticated access. Developers are also advised to enforce rate limiting, authorization checks, and automatic cleanup of unused files to prevent storage abuse and data leaks. The article emphasizes that layered controls — combining validation, logging, encryption, and signed URLs — offer significantly stronger protection than any single security measure alone.

0
ProgrammingDEV Community ·

API Security Checklist Highlights Key Practices Startups Often Overlook

A security guide published on DEV Community warns that most API vulnerabilities at startups stem not from sophisticated attacks but from neglected basic practices during fast-paced development. The checklist covers essential controls including authentication, authorization, input validation, HTTPS enforcement, and rate limiting. It also urges developers to avoid hardcoding secrets in source code and to use environment variables or secret management services instead. Security logging, versioning, and pre-deployment testing for common flaws like SQL injection and broken authentication are also recommended. The guide emphasizes that API security should be built into development workflows from the start, not treated as a last-minute addition before launch.

0
ProgrammingDEV Community ·

Seven Common JWT Authentication Mistakes That Expose Production Apps

JSON Web Tokens are widely used for authentication in web and mobile applications, but security flaws in their implementation can lead to token theft, account takeovers, and unauthorized access. A review of production applications highlights seven recurring mistakes, including storing tokens in insecure locations, omitting expiration claims, and trusting unverified token data. Developers are also warned against embedding sensitive information in JWT payloads, since the data is encoded but not encrypted and can be decoded by anyone. Additional risks arise from neglecting token revocation strategies, reusing signing keys across environments, and failing to enforce server-side authorization checks. Addressing these issues requires combining secure token storage, short-lived access tokens, proper validation, and role-based authorization on every protected endpoint.

CSS text-wrap: balance eliminates orphaned words in headlines natively · ShortSingh