Padding
Padding is the addition or reservation of extra space, positions, or filler values around or within data or content to meet layout, alignment, size, or processing requirements.
Hacking Cryptography
A defined method for adding and later removing padding from cryptographic data, potentially incorporating randomness.
- How it is used
- Fits variable-length plaintext, digest, and signature inputs into fixed-size cryptographic processing units.
- How deep it goes
- Defines several byte schemes, traces oracle and validation failures, and implements SHA-256 padding for a length-extension exploit.
- Examples
- Uses an 8-byte final block, PKCS#7 and ANSI X.923 bytes, PKCS#1 v1.5 signatures, and forged HTTP transaction parameters.
- What you can do after
- Diagnose/debug with it by identifying padding-oracle leaks and enforcing complete structured-padding validation.
Tiny CSS Projects
A CSS property that sets the space between an element's content and its border on each side.
- How it is used
- Uses padding to keep card text, links, headings, and controls comfortably spaced within their containers.
- How deep it goes
- Explains side-specific shorthand, contrasts padding with margin, and shows how border-box changes the space available to content.
- Examples
- Shows padded profile and credit-card faces, checkout-card headers, form controls, and call-to-action links.
- What you can do after
- Apply it through CSS shorthand or side-specific properties to space content, preserve intended layouts, and reset unwanted browser defaults.
Learn Generative AI with PyTorch
A setting or operation that adds, fills, or ignores boundary or placeholder positions in tensor or sequence data.
- How it is used
- Controls convolution output dimensions and standardizes variable-length sequences for batched Transformer computation.
- How deep it goes
- Explains convolution and sequence padding through parameterized examples, code, tensor shapes, masks, and calculations.
- Examples
- Uses a 3 × 3 image, a 2 × 2 filter, padded convolution outputs, token batches, and NumPy sequence-padding code.
- What you can do after
- Apply padding with PyTorch Conv2d and NumPy batch preparation, then configure masks that ignore padded sequence positions.
Read how Learn Generative AI with PyTorch explains padding →
CSS in Depth, Second Edition
The CSS shorthand property that specifies the space between an element's content and its border.
- How it is used
- Uses padding to create space within navigation links and containers, distinguishing it from spacing between elements.
- How deep it goes
- Explains shorthand value order and omitted sides, then works through layout effects rather than providing a complete property reference.
- Examples
- Builds padded navigation links and compares `1em` padding on elements with different font sizes.
- What you can do after
- Operate/configure it to size clickable links, choose internal versus external spacing, and prevent unwanted margin collapse.
Build a Website with ChatGPT
The CSS padding shorthand property sets padding values for multiple sides of an element with one declaration.
- How it is used
- Uses padding to give page content breathing room inside headers, footers, and other element boxes.
- How deep it goes
- Defines padding through the box model and demonstrates side properties and shorthand without advanced layout details.
- Examples
- Demonstrates four-sided header padding and equal footer padding with CSS declarations.
- What you can do after
- Apply it by editing CSS padding values to make page content feel less crowded.
Natural Language Processing in Action, Second Edition
Padding is the addition of extra positions around an input sequence so boundary regions can be processed and output dimensions controlled.
- How it is used
- Standardizes text sequences before embedding and convolution so CNN encodings retain consistent dimensions.
- How deep it goes
- Explains filler tokens, clipping, sequence-length effects, and implementation, but does not develop padding strategies beyond fixed-length sequences.
- Examples
- Uses a reusable Python padding function, a ten-word convolution example, and a CNN configured for sequences of length 40.
- What you can do after
- Build it from scratch by clipping sequences, appending a pad token, and sizing the downstream CNN tensors.
Read how Natural Language Processing in Action, Second Edition explains padding →
Math and Architectures of Deep Learning
The treatment of positions where a convolution kernel extends beyond the input array, such as stopping early or pretending missing values are zero.
- How it is used
- Controls convolution boundaries and output dimensions while preserving or reducing spatial extent.
- How deep it goes
- Defines valid and zero padding, derives output-size reasoning, and connects padding to PyTorch parameters.
- Examples
- Uses size-3 kernels on one-dimensional arrays, boundary figures, output-size equations, and PyTorch Conv1d listings.
- What you can do after
- Apply it via PyTorch by selecting padding alongside kernel size and stride in a convolution layer.
Read how Math and Architectures of Deep Learning explains padding →
100 Go Mistakes and How to Avoid Them
Padding is the insertion of extra memory space between data fields to control their placement and alignment.
- How it is used
- Uses padding to separate concurrently written fields and to explain the memory cost of struct alignment.
- How deep it goes
- Works through a 56-byte separation and a 24-to-16-byte layout change, with a benchmark comparison for the concurrent case.
- Examples
- Contrasts a padded concurrent Result struct with a byte–int64–byte struct whose fields are reordered to reduce its size.
- What you can do after
- Diagnose/debug false sharing with deliberate padding or channel communication, and reduce struct memory use by reordering fields.
Read how 100 Go Mistakes and How to Avoid Them explains padding →
Grokking AI Algorithms, Second Edition
Padding is the addition of extra border values around an input array before an operation is applied.
- How it is used
- Preserves convolutional spatial dimensions and lets filters process image borders and corners.
- How deep it goes
- Explains zero borders, edge coverage, and output sizing, then demonstrates 2D and 3D implementations without deeper convolution theory.
- Examples
- Uses a 3×3 filter scan, zero-padded image, NumPy functions, and a padded multi-channel tensor.
- What you can do after
- Builds padding from scratch for 2D images and 3D feature-map tensors using zero-filled borders.
Read how Grokking AI Algorithms, Second Edition explains padding →
Software Security for Developers
Padding is the addition of extra data so that an input conforms to a required fixed block size or cryptographic encoding format.
- How it is used
- Explains how cryptographic inputs meet fixed-size AES blocks and how RSA encryption gains protection from randomized encoding.
- How deep it goes
- Demonstrates block sizing and contrasts RSA schemes, but stops short of specifying padding bytes or implementing padding code.
- Examples
- Uses a 1,605-byte AES message and RSA comparisons between OAEP and PKCS#1 v1.5.
- What you can do after
- Evaluate padding choices by matching AES block requirements and preferring OAEP over RSA PKCS#1 v1.5.
Read how Software Security for Developers explains padding →
Deep Learning with R, Third Edition
Padding is the addition of rows and columns around an input feature map so convolution windows can cover boundary locations.
- How it is used
- Uses padding to preserve convolutional spatial dimensions and rectangularize variable-length text batches.
- How deep it goes
- Defines boundary and sequence padding with concrete dimensions and API choices, but defers detailed masking and convolution arithmetic.
- Examples
- Uses 5 × 5 feature maps, 3 × 3 windows, padded IMDb reviews, and an R/Keras TextVectorization pipeline.
- What you can do after
- Apply padding through Conv2D modes or TextVectorization output_sequence_length when constructing image and text pipelines.
Read how Deep Learning with R, Third Edition explains padding →
Real-World Cryptography
Padding is the addition of structured data to an input so it can be divided into required-size blocks while preserving input boundaries.
- How it is used
- Uses structured bytes to align cipher and hash inputs, recover message boundaries, and sometimes conceal plaintext length.
- How deep it goes
- Explains reversible PKCS#7 rules, hash preprocessing, and TLS length-hiding tradeoffs without descending into implementation details.
- Examples
- Demonstrates eight-byte AES padding, PKCS#7 full-block padding, SHA-256 block preparation, and TLS record length hiding.
- What you can do after
- Apply it via established padding rules when preparing block-cipher or hash inputs, while recognizing that length hiding remains imperfect.
Web Design Playground, Second Edition
A padding shorthand property is a CSS declaration form that specifies multiple padding side values in one property.
- How it is used
- Uses padding shorthand to create whitespace inside element boxes and improve readability, grouping, and navigation spacing.
- How deep it goes
- Defines padding, lists its units and side properties, demonstrates a four-value shorthand, and stops short of deeper layout theory.
- Examples
- Demonstrates a pull quote and a horizontal navigation menu with added item spacing.
- What you can do after
- Build it from scratch by writing compact padding declarations for content boxes, pull quotes, and navigation items.
Read how Web Design Playground, Second Edition explains padding →
Deep Learning with Python, Third Edition
- How it is used
- Preserves a feature map’s spatial dimensions by adding rows and columns around its input.
- How deep it goes
- Explains border effects with a 5 × 5 example and defines `valid` and `same`, without detailing padding implementation.
- Examples
- Compares 3 × 3 windows on a 5 × 5 feature map with and without padding.
- What you can do after
- Configure padding in Conv2D using `valid` for no padding or `same` to preserve spatial dimensions.
Read how Deep Learning with Python, Third Edition explains padding →
Web Design Playground
The inner spacing between an element's content and its border.
- How it is used
- Uses inner whitespace to organize page content and keep text, borders, and navigation items from feeling crowded.
- How deep it goes
- Defines padding within the box model and demonstrates side-specific properties, measurement units, shorthand, and navigation spacing.
- Examples
- Shows a pull quote with unequal side padding and an unordered-list navigation menu spaced with padding-right.
- What you can do after
- Apply it via CSS properties or shorthand to add controlled inner spacing around element content.
LLMs in Production
Padding is the addition of placeholder elements to sequences so that inputs in a batch share a common length.
- How it is used
- Supports batch tokenization and recurrent-model processing by equalizing variable-length input sequences.
- How deep it goes
- Defines placeholder-token padding and maximum-length extension, but defers masking and detailed padding strategies.
- Examples
- Uses a <PAD> tokenizer token and packed embeddings extended to the longest sequence in a Twitter sentiment dataset.
- What you can do after
- Apply it via Hugging Face tokenizers or packed embeddings to prepare variable-length sequences for batch processing.
Design for Developers
Padding is the internal space between an element's content and its border or edge.
- How it is used
- Uses padding to maintain consistent vertical rhythm across typography and interface components.
- How deep it goes
- Explains padding through baseline multiples and a body-copy calculation, but stops short of component-specific implementation.
- Examples
- Demonstrates 16px top spacing with 20px line height to reach a 36px baseline-compatible total.
- What you can do after
- Apply padding using baseline multiples and check its effect on typographic alignment and readability.
Modern C, Third Edition
Byte padding is unused whole-byte storage inserted within or after a structure to satisfy layout or alignment requirements.
- How it is used
- Explains wasted storage and alignment effects in structure layout.
- How deep it goes
- Defines placement rules and reduction by member ordering, while deferring alignment details to a later treatment.
- Examples
- Uses a person structure layout and contrasts byte padding with compact time-related bit-field declarations.
- What you can do after
- Evaluate structure layouts and reduce potential waste by considering member order.
Math for Web Design
The CSS padding property specifies the space between an element's content and its border.
- How it is used
- Uses padding to create content-to-border space and calculate predictable element dimensions in fixed, inherited, percentage, and responsive layouts.
- How deep it goes
- Calculates box dimensions, containing-block percentages, inheritance behavior, and fluid values, but stops short of browser implementation internals.
- Examples
- Uses fixed-width boxes, inherited percentages, parent-width calculations, and clamp-based fluid gutters as concrete examples.
- What you can do after
- Diagnose sizing surprises and apply fixed, inherited, percentage, or fluid padding using explicit CSS calculations.
Related concepts
- CSS box modelpart of · The CSS box model represents each element as a rectangular box comprising content, padding, border, and margin areas.
- margin propertycontrasts with · The CSS margin property specifies the outer space around an element’s border, separating it from neighboring content.
- style propertykind of · A style property is a named setting or interface attribute that specifies or exposes a presentation characteristic of an element or view.
- emuses · The em is a CSS relative length unit whose computed value is based on the applicable font size.
- shorthand propertykind of · A CSS shorthand property sets multiple related longhand properties in a single declaration, resetting omitted properties to their initial values.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


















