Freemote Logo

Coding Wiki

Most Common Coding Questions

Find answers to popular programming questions and level up your coding skills

How to make top 2 corners rounded only css

Learn how to round only the top 2 corners of an element using CSS.

Answer:

To make the top 2 corners of an element rounded in CSS, you can use the border-radius property.

css
border-radius: 10px 0 0 0;

In this code, the first value (10px) sets the radius for the top-left corner, and the subsequent values set the radii for the other corners to zero.

Alternatively, you can use negative values to make only the top 2 corners rounded:

css
border-radius: -10px -0 0 0;

This will set the radius for the top-left corner to -10px and the top-right corner to 0, effectively making only those corners rounded.

Note that the border-radius property only affects the edge of an element, not its padding or background color.

css
Tags:
css
☾☾☾
+++++++++
Level Up Your Coding Skills

CSS Cheat Sheet

Remember the essentials of 5 different languages, it's free.