Food inflation on items like milk, bread and cereals has also come down, although remains high - at 14.9%.
To help slow price rises, the Bank of England has increased interest rates 14 times to 5.25%.
What does inflation mean?
Inflation is the increase in the price of something over time.
If a bottle of milk costs £1 but £1.05 a year later, then annual milk inflation is 5%.
How is the UKʼs inflation rate measured?
The Office for National Statistics (ONS) tracks the prices of hundreds of everyday items in an imaginary "basket of goods".
The basket is constantly updated to reflect shopping trends, with the most recent changes adding frozen berries and removing alcopops.
Each monthʼs inflation figure shows how much these prices have risen since the same date last year.
You can calculate inflation in various ways, but the main "headline" measure is the Consumer Prices Index (CPI).
CPI was 6.8% in the year to July, down from 7.9% in June.
What is "core inflation"?
"Core inflation" excludes the price of energy, food, alcohol and tobacco,
This measure was was 6.9% in July, unchanged from June which was the highest level since 1992.
The Bank of England considers this number as well as CPI when deciding whether to alter interest rates.
Why are prices rising so fast?
Soaring food and energy bills have helped drive inflation up.
Oil and gas were in greater demand as life got back to normal after Covid. At the same time, the war in Ukraine meant less was available from Russia, putting further pressure on prices.
The war also reduced the amount of grain available, pushing up global food prices.
This effect was compounded in the UK in February by a shortage of salad and other vegetables, which took food inflation to a 45-year high.
Alcohol prices in restaurants and pubs have also risen.
How does raising interest rates help to tackle inflation?
The Bank of England has a target to keep inflation at 2%, but the current rate is still well above that.
The traditional response to rising inflation is to put up interest rates.
This makes borrowing more expensive, and can mean some people with mortgages see their monthly payments go up. Some saving rates also increase.
When people have less money to spend, they buy fewer things, reducing the demand for goods and slowing price rises.
Businesses also borrow less, making them less likely to create jobs, and may cut staff.
In August, the Bank increased interest rates for the 14th time in a row, taking the main rate to 5.25%.
Are wages keeping up with inflation?
Official figures showed that - on average - regular pay excluding bonuses grew by 7.8% between May and July, compared to the same period a year earlier.
This matches the rate of inflation, which means real wages stayed flat for the first time in two years, rather than falling behind.
However unions point out that many workers have received smaller pay increases, and there have been widespread strikes over pay.
The government has argued that big pay rises could push inflation higher because companies might increase prices as a result.
What has happened to pay in the UK?
Will pay rises for doctors and teachers cause inflation?
When will inflation go down?
Lower inflation doesnʼt mean prices fall. It just means they rise less quickly.
The Bank of England has predicted inflation will drop to 5% by the end of 2023, rather than the 4% it had been anticipating.
Bank governor Andrew Bailey said it was "crucial that we see the job through" and get price rises back to the 2% target, because people "should trust that their hard-earned money maintains its value".
But he admitted that price inflation has been "more sticky than previously expected".
The Office for Budget Responsibility (OBR), which assesses the governmentʼs economic plans, previously predicted inflation would fall back to 2.9% by the end of the year.
In January, Prime Minister Rishi Sunak said halving inflation by the end of 2023 was one of the governmentʼs five key pledges.
Is Sunak keeping his five key promises?
Whatʼs happening to inflation and interest rates in Europe and the US?
Other countries have also been experiencing a cost-of-living squeeze.
Many of the reasons are the same - increased energy costs, shortages of goods and materials, and the fallout from Covid.
The annual inflation rate for countries which use the euro was estimated to be 5.3% in the 12 months to July, stable compared to June and down from 6.1% in May.
The European Central Bank has also been increasing interest rates to try to bring eurozone inflation down.On 2 August, it moved its key interest rate - the benchmark deposit rate - to 3.75%,the highest level for 22 years.
In the US, inflation was 3.2% in the year to July. It was 3% in the 12 months to June, down from 4% in May, after the 12th consecutive monthly fall.
As a consequence, in July the US central bank put up its key interest rate again to between 5.25% to 5.5%. It is the 11th increase since early 2022, and also the highest level for 22 years.