Why doesnt this center my image?

.galaxyjpg {
display: block;
margin-left: auto;
margin-right: auto;
}

(greater than)a href=“http://asdasd.com” title=“DON’T CLICK” class=“galaxyjpg” >

Your element needs a width.

Your not defining the location of an image. Only a url.

A block element is going to align to the normal flow of the block formatting. So margin auto is working as intended just not how you intended it. Try to use display: flex.

9.4 Normal flow

Boxes in the normal flow belong to a formatting context, which may be block or inline, but not both simultaneously. Block-level boxes participate in a block formatting context. Inline-level boxes participate in an inline formatting context.

9.4.1 Block formatting contexts

Floats, absolutely positioned elements, block containers (such as inline-blocks, table-cells, and table-captions) that are not block boxes, and block boxes with ‘overflow’ other than ‘visible’ (except when that value has been propagated to the viewport) establish new block formatting contexts for their contents.

In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block. The vertical distance between two sibling boxes is determined by the ‘margin’ properties. Vertical margins between adjacent block-level boxes in a block formatting context collapse.

In a block formatting context, each box’s left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch). This is true even in the presence of floats (although a box’s line boxes may shrink due to the floats), unless the box establishes a new block formatting context (in which case the box itself may become narrower due to the floats).

For information about page breaks in paged media, please consult the section on allowed page breaks.

https://www.w3.org/TR/CSS2/visuren.html#propdef-display