The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →For a standalone image in normal page flow, make it a block and set its inline-start margin to zero and its inline-end margin to auto. In a typical left-to-right layout, that places the image at the left edge of its container. If text should wrap beside the image, use a float instead; if the image is in a flex row, align it through the flex container.
Choose the method that matches your layout
| Technique | Use it when | Behavior and caveat |
|---|---|---|
| Block image with margins | The image stands alone in normal document flow. | Places the image box at the container’s start. Remove any centering margins already applied. Logical start may be the right side in a right-to-left writing direction. |
float: left |
Text or other inline content should wrap beside the image. | Floats the image to the left and lets text flow around it. Add spacing and manage where subsequent content resumes. |
| Parent flex alignment | The image is a flex item. | Positions items along the flex container’s main axis. The axis depends on flex-direction, and alignment belongs on the parent. |
These methods are not interchangeable. Start with the layout model already used by the surrounding content. For a single image with no wrapping, use block positioning. For editorial text wrapping around a photo, use a float. For items arranged in a flex row, adjust the flex parent rather than trying to position its child as if it were in normal flow.
Place a standalone image at the left edge
Use a class so the rule applies only to the image you intend to position. Keep alternative text meaningful if the image conveys information; use an empty alt value only when it is decorative and adds no information.
<img class="photo" src="photo.jpg" alt="Description of the image">
.photo {
display: block;
margin-inline-start: 0;
margin-inline-end: auto;
max-width: 100%;
}
An img is inline by default. Setting it to display: block makes it a block-level box whose margins can position it predictably. The zero start margin anchors the box at the start of its containing block; the auto end margin takes up the remaining horizontal space. In an ordinary left-to-right horizontal layout, start is left and end is right.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
max-width: 100% is a sizing safeguard, not an alignment rule. It prevents the image from exceeding a narrower parent when the image’s intrinsic width is larger. It does not enlarge a small image to fill the container. Leave its intrinsic dimensions or add an appropriate width rule if a different size is required.
When “left” means the physical left edge
Logical properties adapt to the writing direction. That is generally preferable for pages that may be translated or use right-to-left text. If the requirement is specifically the physical left side regardless of writing direction, use physical margins instead:
.photo {
display: block;
margin-left: 0;
margin-right: auto;
max-width: 100%;
}
Choose either the logical or physical pair for the intended behavior; do not add conflicting declarations for both without a specific reason.
Rank #2
Remove rules that center the image
A stylesheet rule such as margin: 0 auto, margin-left: auto, or margin-inline: auto can center a block image. Remove or override the rule that applies to the image. If a more specific selector or a later stylesheet declaration sets the margins, changing a less specific rule may have no visible effect. Inspect the computed styles in your browser’s developer tools to find which declaration wins.
Let text wrap beside the image
A float is appropriate when surrounding text should flow around an image. The obsolete HTML align="left" attribute was associated with this kind of behavior, but new code should use CSS.
<img class="article-photo" src="photo.jpg" alt="Description of the image">
<p>Text that should flow beside the image and continue below it when it reaches the image's height.</p>
.article-photo {
float: left;
margin: 0 1rem 1rem 0;
max-width: 100%;
}
The right and bottom margins create breathing room between the image and nearby text. A float changes how following inline content flows, so it is not the right solution when the image should occupy its own line without wrapping.
Rank #3
Control where content resumes
If a later section must begin below the floated image rather than beside it, clear the float. For example, apply a class to the element that starts after the floated content:
.next-section {
clear: left;
}
Alternatively, contain the float in a parent whose layout is designed to contain its children. The important question is whether the following content belongs alongside the image or should start beneath it. Choose the float and clearing behavior to match that intended flow.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Align an image that is inside a flex row
When the image is a child of a flex container, use the parent’s main-axis alignment. With the default row direction, the main axis is horizontal:
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
.gallery {
display: flex;
justify-content: flex-start;
}
<div class="gallery">
<img src="photo.jpg" alt="Description of the image">
</div>
justify-content acts on the flex container, not on the image. flex-start follows the flex direction, while start is writing-mode-aware. If the flex direction changes to a column, the main axis is vertical, so justify-content no longer controls horizontal placement. For horizontal positioning in that case, consider the cross-axis alignment property or change the layout direction as needed.
An auto margin on one flex item can also consume available space and push it away from other items. Use that when the design calls for that item-specific spacing; use parent alignment when the row’s overall item placement is what should change. If the image is not a flex item, changing justify-content on some unrelated parent will not move it.
Make the image behave well on small screens
Keep the image within its containing block with max-width: 100% when it might otherwise be wider than the available space. This is useful for a standalone image and a floated image, but it does not decide whether text wraps or which side the image occupies. Alignment, sizing, and text flow are separate concerns.
Best Value
Check the actual image and its parent when a layout looks wrong on a narrow screen. A parent with its own width or overflow rules can affect what is visible; the image’s alignment rule cannot correct a container that is itself misplaced or clipped. If using a float, remember that wrapping continues only while there is room alongside the floated box; at narrower widths, text may flow below it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common alignment problems
- The image is still centered. Look for
margin: 0 auto, auto side margins, or a centering rule on a more specific selector. Check the computed margin values and override the declaration that is actually winning. justify-contenthas no effect. Confirm that the image is a child of an element withdisplay: flex. Applyjustify-contentto that flex parent, then check whether its main axis is horizontal.- Text wraps when it should not. A float is designed to let content flow around the image. Remove
float: leftand use standalone block placement or a suitable non-floating layout. - The image overflows its container. Add
max-width: 100%to constrain it to the available width. If it still appears clipped, inspect the container’s sizing and overflow behavior. - An old example uses
align="left". Replace the obsolete HTML attribute with a CSS rule suited to the intended layout: block margins for a standalone image, orfloat: leftwhen wrapping is wanted. - The result changes in a translated page. Decide whether the design means logical start or physical left. Use inline-start/end margins for direction-aware placement, or left/right margins for the physical edge.
Or skip the browser setup
If you need a screenshot of a page to check how its layout renders, ScreenshotNeo can capture it through one GET request. The API captures the supplied URL; it does not replace the HTML and CSS changes above. Its clean-shot options remove cookie or consent banners, newsletter popups, and chat widgets before capture, and each step can be turned off. Bot checks, blank pages, timeouts, and failed loads are not billed; cache hits are not billed either, and the response includes X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Every feature is on every plan.
Example cURL request, using the ScreenshotNeo API’s documented endpoint and parameters:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for setup and options. The service supports PNG, JPEG, WebP, or PDF output, and its options include full-page capture, CSS selectors, viewport and device settings, custom CSS and JavaScript, waiting rules, and request blocking. Find out more at ScreenshotNeo.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesSign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Frequently Asked Questions
Does text-align: left align an image?
It aligns inline content inside a text-aligned block. It can affect an inline image, but block margins or the parent layout are clearer choices when you need to position a block image.
Should I use align="left" on an image?
No. The HTML image alignment attribute is obsolete; use CSS for new work.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.

