How to Center an Image in CSS Very Easily

center image in css

There are few pointers to center an image in CSS.

  • First, make sure that the parent element of the image has its width set.
  • Second, the image should not be wider than its parent element, that’s pretty obvious.

See also:  How To Center A Div Inside A Div Easily

Center and Image in CSS horizontally

Images are the same as divs, you can use the text-align into its parent element but not the margin: 0 auto alone on the image.
To center image in div, set a width of the div then add margin:0 auto and display: block into the image in CSS.

The HTML code:

  1. <div class="wrapper">
  2.  <img src=""></div>

The CSS styles:

  1. .wrapper{
  2. width: 100%;
  3. height: 300px;
  4. border: 2px solid #93c504;
  5. }
  6. img{
  7. max-width: 250px;
  8. display: block;
  9. margin: 0 auto
  10. }

This will result into an image centered horizontally:



See the jsfiddle:

Make sure you have a smaller image width than the parent element.

The margin’s first value 0 was for the top and bottom margin. While the second is for left and right margin.

You can also set margin-left: auto and margin-right: auto on the image in CSS.

Center an Image in CSS horizontally and vertically

We will going to use the span element to guide our image  making it center. Setting an image with margin and text-alignment could not make our image center align.

The HTML code:

  1. <div class="wrapper">
  2.  <span class="for-image"></span>
  3.  <img src=""></div>

The CSS styles:

  1. .wrapper {
  2. width: 100%;
  3. height: 300px;
  4. border: 2px solid #93c504;
  5. text-align: center
  6. }
  8. .for-image {
  9. height: 100%;
  10. display: inline-block;
  11. vertical-align: middle
  12. }
  14. img {
  15. max-width: 200px;
  16. height: auto;
  17. background: #3A6F9A;
  18. vertical-align: middle
  19. }


Responsive design images

Creating a responsive design image is very useful for mobile devices.

Responsive image will automatically scale down and adjust to the width of the device.

To create a responsive design image, you just set a max-width: 100%; and height: auto; into the images.

The max-width: 100%; means the image’s width will cover all its parent’s width. You can also set a natural image width(full resolution width of the image) to the max-width property so it will not be basing upon its parent element’s width.

The height: auto; makes the image height and width proportional. As a result, it would not stretch.

What happens if you will not set a height: auto; is, the image’s original height will still be the same while the width is scaling according to the device’s width, so it will be non-proportional.

How to Type on a Path in Photoshop Using Shapes and Pen tool


The regular left to right horizontal text direction was often used by any design graphic you have seen. Creating a custom path to the type to follow makes the texts come into life and suggests creativity. So, How to type on a path in Photoshop?

Watch the video below or continue reading.

See also:

Make a GIF from a Video Just Like in Tumblr

  • Using the Pen tool
  • Basic Shape tool

We can use the pen tool to create freedom path so we can customize whatever we want it to look. Also using the basic shape tool.

How to Type on a Path in Photoshop Using the Pen tool?

Use the pen tool to create a freedom path. It creates a straight line segment after left clicking. Use the pen tool by left clicking, it will create an anchor point which a line segment is created.


In this tutorial, I will create a simple custom curved path for the type to follow.

This is the final design that we will implement.


First, I will create a red mark so you can see what we will be creating. The red line mark indicates the path we are going to create.


Next, we are going to use the pen tool to implement our line mark.
Since I am going to type on a path, I need to change the pen tool into path mode. In this mode, we cannot get the option to add fill or stroke. You can find the option in the top menu (see image below).

After we change the pen tool mode, I am going to create three points on our image. I did this to we can create a precise or at least balance within the curve path.


Notice some anchors of the path is on point, I’m going to make it curve so our text will not overlap. Using the pen tool, hover over the center point. Hold the ALT/Option key in your keyboard and you will see a triangle cursor symbol(see image below). Click and drag it to the right while holding the shift key until you find the right curved.


Finally, by selecting the horizontal type tool I am going to hover over to the path and you will see a type on a path symbol(See image below).


Type on a path symbol


Click on it and start adding your texts.

After adding my texts, click on the check mark at the top to commit your current edit. My text was not so appealing so I will change the size, font and color.

This is what I came up with:


What if we want to change a position of the text starting point?

Well,  I can by using the path selection tool.


Using the path selection tool


  • Change the length path segment
  • Flip text on path photoshop

Change the length path segment

When you hover over the path, you will see a type symbol cursor with a triangle flag (See image below).

cursorpath_selection_facing_left cursorpath_selection_facing_rightl

In your freedom path, if the cursor flag faces to the left it means that it will control the end point of the segment. If it is facing to right, it will control the starting point of your text types.

Flip text on path photoshop

If you want your text to face downwards, use the path selection tool then hover over your path until you’ll see a path selection cursor having a flag symbol and click and hold down. As a result, you will see a flip text on path.


In addition, if you are unable to see the path when selecting the path selection tool, just click on the different layer and click back again to the text layer.

This is the final image I created:

How to Type on a Path in Photoshop Using the Basic shape tool?


  • Rectangle tool
  • Rounded rectangle tool
  • Ellipse Tool
  • Polygon tool
  • Line tool
  • Custom shape tool


I am going to create a path using the ellipse tool. In the same way, make the tool mode into shape.

text on a shape path

I will be going to create the path surrounding the orange object in our image.
First, holding the shift key( to create a perfect circle ), click the center of our object and drag to expand the size of the shape.

Second, select the type tool and hover over the path you just created then click and start typing. Use the path selection tool to adjust the position.

It is pretty much the same process the only thing different is the shape of the path that is going to create.

Style your text the same as the regular horizontal align.

Here are some few examples I made:

baskets_example text on a path

cat_example text on a path
Image Credit :

In conclusion, you can create text on a path using freedom pen tool or using the basic shapes tool. The pen tool makes it more freely to create custom path while the shape tool might be useful if you want to create a perfect shape path for your text types.

Background Image Color Overlay | Create a Filter Look with CSS


To add a color overlay to the background image, I am going to use CSS.

First of all, adding a CSS background image color overlay is the most dynamic way of creating tinted web page images. It became popular to many websites which appear in homepage as banners.



The great thing about adding background image color overlay is that you can just change any image (normal image without filter) dynamically and publish it on your website with filter, thanks to CSS.

So, how to do it?

Watch the video or continue reading.

See also:

Add a background property

(Yes not a background-image or background-color).

Within the background property, I add a linear gradient and a URL to the image.  I am using a linear-gradient background with transparency.

  1. background:
  2.    linear-gradient(
  3.    rgba (255, 255, 255, 0.5),
  4.    rgba (255, 255, 255, 0.5)
  5.    ),
  6.    url(image.jpg)

In one CSS property, I need to set two backgrounds. The first one is the linear-gradient color and the second is the actual image.

Because I need to add transparency for the background color opacity, I will define RGBA inside the linear gradient.


  1. linear-gradient(
  2.    rgba (255, 255, 255, 0.5),
  3.    rgba (255, 255, 255, 0.5)
  4.    );

The RGBA is an RGB color with an alpha channel. The alpha channel must be set between 0.0 to 1.0. It is the last parameter of the RGBA. The RGBA parameters are composed of red, green, blue, alpha.

Example: rgba (255, 255, 255, 0.5)

How to choose and get a color?

To make it easier for you to choose the color, create your web page document copying the code from here. Open it in the browser.

Developer tool in your browser is your friend. Right-click and inspect your web page (or CTRL+SHIFT+I).

On your div with the background style, click on the colored square or circle and a color picker will appear. Choose your color by dragging into the palette.


Change the opacity of the color you’ve picked, that is important so we can mimic the overlay or color filter effect in photoshop with our background image.

You can also use CSS Gradient Generator from sites like colorzillacssmatic, or cssportal.

See the jsfiddle:

Use the background-blend-mode

Are you familiar with Photoshop blend modes?

Well, I can also blend our background but with CSS.

I can also use the linear-gradient without the transparency and add a background-blend-mode: soft-light;

The CSS code should look like this:

  1. .block {
  2.  height: 350px;
  3.  background: linear-gradient(yellow, yellow), url(image.jpg);
  4.  background-size: cover;
  5.  text-align: center;
  6.  background-blend-mode: soft-light;
  7. }

As a result, the image and the color blended together in soft-light. Unlike the other way in which I can adjust the opacity.

You can experiment by adding different value into the background-blend-mode property.

background-blend-mode values include:

  • normal
  • multiply
  • screen
  • overlay
  • darken
  • lighten
  • color-dodge
  • saturation
  • color
  • luminosity

CSS Background image color overlay in hover

Add a background image color overlay if the user hovers over the image.

In conclusion, adding the color filter effect can be done in two ways. The first is through a background property with the linear gradient and image url.

The other is to add a solid color within the parameter of linear-gradient and add the background-blend-mode property.

Creating a Hero Image with color filter overlay on hover

Hero image is a large website banner image. It is composed of the background image, texts and even a button.

Learn how to create your hero image with CSS background image color overlay by watching the video below:

You can use either of the two techniques to add the effect into your CSS background image.

Disable Right Click with Javascript

Disable right click with javascript

Disable right click to prevent end users the capabilities to inspect, print, or copy.

I do not recommend adding this into your web-pages but here is the tutorial.

Disable right click with javascript

Disable right click and content copying

Preventing the user from copying your content may also be one of the reason why you want to disable the right click function. It may be useless because someone can manage to use the shortcut key Ctrl+C to copy. Using CSS is a better way to prevent the user from copying.

Try to look at the code below and right-click on the result tab.

Find out how to disable a user from copying your texts using CSS:

Just make sure you also disable the right-click function so a user cannot inspect through right-clicking.

Disable right click on images

The major reason to disable the right-click is to prevent the users from inspecting your code. Preventing them also disable them to download images.

Try to look at the code below and see how the JavaScript function is used to disable the right click into images.

Did you know, a user can also get your images through downloading the whole web document?

The document will have the webpage’s HTML, CSS, JS, images and other files that can be viewed without an internet connection. Images inside the downloaded document were the actual image from a live web page.

Another thing, a user can also use the page info feature in firefox browser to find the image by going to the media tab and clicking on the links to preview the image.

The only problem is, a user can disable the JavaScript in the browser. Hence, the script added would not run.

A user can disable JavaScript in Chrome by going to this path: chrome://settings/content .


Under JavaScript, there are two radio options allow and disallow JavaScript.

In Mozilla Firefox, the user can disable JavaScript by going to this path: about:config within the browser.


Next, click the button saying “I accept the risk”. Search for JavaScript, then right-click and click on toggle.

This will turn JavaScript into false indicates that it is now disabled.

I would not recommend disabling right-click function but if for some reasons / for debugging purposes etc or even a first steps to protect your own copyright images.

Make a GIF from a Video Just Like in Tumblr

make a gif from a video

You must have seen moving images on tumblr or on any website or an advertisement. Almost all the tumblr images you have seen is a gif image format and most of them was created from a video. So, how can we make a gif from a video file?

First, let’s talk about what is a gif image.

A gif or Graphics Interchange Format supports animations of up to 256 colors for each frame.

It is a palette based which only hold up to 256 colors.

So, what are the requirements to be able to convert a video into a gif image?

  • Photoshop
  • Quicktime Player -An application required by Photoshop. Use to import and render frames within the video. It is capable of handling various formats like video and image. Download the player here.
  • Video file

What Photoshop does is it gets the frames from the video and converts it into layers.

The layers then used in the animation frames in the gif image.

Step 1 Import the Video


Open Photoshop. Head over to the top menu and click on File-Import-Video frames to layers.

An Import Video to Layers window will pop-up.

Step 2 Select Range to Import


There are two options to choose from, from beginning to end or selected range only.

Most of the time you will choose the selected range since the option will take all the frames within the video.

It also depends on the video on how much frames it has every second so it would avoid creating hundreds of frames.

Use the trim control guides to select the range and duration.

See arrows within the figure above.

Step 3 Make frames from Layers


The frames will become layers now.

Depending on the range you selected is how much layers you will have.

Now, we will open the timeline or animation tab. 

Click on the window on the top menu and choose timeline.

It should open a tab/panel with your layers into it.


For an older version of Photoshop, you will select the animation option.

An animation tab will open.

If there will be no frames click on the toggle menu at the right side of the tab.

Select make frames from layers.

See 1 : Make sure you choose the forever in the loop option so the animation will loop again and again in our gif image.

See 2: If you have something to edit/change within you frames, click on this toggle icon and it will be converted into a video timeline.

In video timeline you can adjust the frame’s specific duration, style, position and opacity.


Step 4 Saving into a GIF Image

To save a gif image, click on file-save for web or hit Alt+Shift+Ctrl+S.


On the save for web window, make sure you select the GIF (see 1) file format.

Adjust how many colors we want lesser than 256 (see 2).

The colors within the image you created are seen at the color table (see 3).

Decrease the colors and the color table will also eliminates a color.

Lessening the colors as a result the image will be grainy so it is best to leave it at 256 colors.

We can also adjust the image size, width and height.

Save it by hitting save and test it by opening with browsers like chrome and firefox.

Now we have created a gif image from a video using Photoshop.

Adobe Photoshop for Beginners Tutorial (Part one)


Photoshop is a graphic editor software developed and published by Adobe Systems. It has been used widely used because of its useful functions to either simple or complex graphic related creations. Learn Adobe Photoshop for beginners’ basic tips and tools description provided below.


When you accidentally closed a panel in your workspace or if you forgot where it is and you can’t find it window menu is a great help. Click on the window menu on the top and you’ll find the options you were looking for.


Workspace is a great way to set your Photoshop interface according to the kind of projects you are working.

For example, if you are working on Image color adjustments in Photoshop then you need histogram and adjustments panel so you would choose the Photography workspace set by Photoshop for you. Go to Windows- Workspace –Photography then a panel dedicated to Image adjustments appear.

You can also create your own workspace if you want a customize tools/panels to appear on your interface. First, Display your desired panels and when done just go to Window- Workspace- New Workspace. A window pops up to fill in the workspace name and hit save.


Rulers are located on the top and the left side of your canvas. If you can’t find it just go to View-Rulers. There are two of it, the horizontal and vertical. Add a ruler guide to your canvas by clicking and dragging it to your canvas.

rulers-in- Adobe Photoshop for beginners


Do you have loads of work to be done and you took the same steps over again? Creating an action saves a lot of time.


Didn’t know the name or the shortcuts of the tools located on the left-hand side? Hover over the tool and information about it will tip up. You could also click on the tools that have caret which means that it has another option with the same kind of tool for you to choose. If it is not available in your workspace, you can find it be clicking on Window- Tools.

PSD File

JPEG is a compressed image format. Saving your work in this format is not the better idea if you want to resume editing. Save it as a PSD file format and you’re good to go.

Smart Object

Making a layer into a smart-object is a non-destructive technique. It acts as a pre-compose layer file. It preserves image or shape’s original quality when you resize an image to smaller and vice versa.

To make the layer into a smart-object, right-click on it and choose make layer into smart object.

See also:


Do not like the default dark gray interface color of your workspace? Change it by going to edit menu-preferences-interface and choose your desired color theme.


Grids are your friends. You might want to use grids so that you can position objects evenly or specifically on your canvas.

How To Disable Text Selection With CSS User Select

css user select

By default, texts on any web page can be highlighted and copied. Disable the highlight function also disables someone to copy the texts in the document. Using CSS user select makes the texts unselectable.

If for some reasons, you do not want your texts inside the button or paragraph to highlighted. CSS user select style attribute might help you.

So how to disable text selection with CSS user select?

Learn how by watching this video or continue reading.

See more amazing CSS videos in youtube: Garnatti one

Target an element and add the following styles

-webkit-touch-callout: none;

It is self-explanatory, add these styles disable the text selection.
Try to select the sentence demo below. This sentence was added with the CSS user select styles.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Notice that you cannot highlight the sentence above means the styles that added worked.

The-webkit-touch-callout attribute targets the ios safari browser, -webkit-user-select targets Chrome, Opera and Safari browsers, -khtml-user-select targets Konqueror, -moz-user-select targets Mozilla firefox and -ms-user-select:none targets internet explorer.

You can use this technique if you want to…

Prevent people from copying your content. Unfortunately, it can be useless if people inspect your code from the browser. They can just copy the content within the source code.

Do not want somebody to copy your contents? The better way is to disable the right-click mouse function.

How To Link CSS To HTML | Step By Step

how to link css to html

There are three ways to link css to html: inline, internal and external stylesheets.

Here is the video you can watch to better see how the different stylesheets are implemented or continue reading for a detailed explanation.

See more amazing CSS videos in youtube: Garnatti one

1. Inline

Use inline style if you want to add a style uniquely to an element. Just add style attribute to the chosen element/tag and then add the style attribute and value.

<h1 style=”font-family:arial; color:red”>Hello World !</h1>

2. Internal

If you want your css to be within the same page as your webpage then internal css stylesheet is for you. Inside the head section add an opening and closing style tag. In the opening style element, add type attribute equals to ”text/css” .

<style type=”text/css”> </style>

Between your opening and closing style tags add desired styling attribute by targeting elements.


<style type=”text/css”> h1{
	font-family: ‘arial’;
	color: red;
} </style>

3. External

If you want your files to be organized then use external css stylesheet. Create a css file and save(the same level with the html file).

Name your css file whatever you want I name mine as style.css. Inside in your head section in html add a link tag to link our css file.


<link rel=”stylesheet” type=”text/css” href=”style.css”>

We can now add styles inside our style.css file just like the internal css styles above but without the open and closing style tags.

How To Center A Div Inside A Div Easily


Why do we center a div inside a div element? Notice most of any website’s main content block always on the middle or a picture perfectly aligned on the middle.

There are a lot of ways to center a div inside a div. In this tutorial, I am going to show you two different ways to center a div element inside another.

These two videos might help you.

See also:  Center Align Texts in Vertical Position
Continue reading below if you don’t want to watch the video.

Margin to center a div

Make the margin of the child div (the div inside the div) set to zero and auto.

  1. .child-div{
  2.   margin: 0 auto;
  3. }


Notice the code above we have set the first value to zero. The zero value is the margin from the top and also from the bottom of the div. In the second value, we have not set a numeric value but an auto which makes the div go in the middle horizontally. It is the margin from left and right of the div.

Note: Make sure to set a width in your child and parent div for this to work. The parent div should have a greater width obviously.

Text Align to center a div

  1. .parent-div{
  2.   text-align: center;
  3. }

Telling the parent div to make its child’s text elements to center also makes the child div to center horizontally. As a result the texts inside our child div are also centered. Therefore, the last thing we need to do is to keep the text aligned to the left.

The solution, we should target the child div and add a CSS style but this time text alignment to the left or wherever you prefer.

how to center a div inside a div


  1. .child-div{
  2.   text-align:left;
  3. }

See more amazing CSS videos on youtube: Garnatti one

In conclusion, the two CSS styling techniques are both great methods to use to align a child div element in the middle. The margin attribute is better than the other since it will make your code lesser and simpler.