His self-titled debut album was released in May 2017, whereupon it debuted at number one in several countries, including Australia, the UK and the US. The record was heavily influenced by 1970s soft rock and was described by Variety as a "classic cocktail of psychedelia, Britpop, and balladry". The album received generally favourable reviews from critics, and was included in several publications' lists of the best albums of 2017. Harry Styles yielded two more singles, "Two Ghosts" and "Kiwi". The film, Harry Styles: Behind the Album, which documented the writing and recording process for the album, was also released in May exclusively on Apple Music. Styles embarked on his first headlining concert tour, Harry Styles: Live on Tour, from September 2017 through to July 2018, performing in North and South Americas, Europe, Asia, and Australia. The tour setlist included covers of Fleetwood Mac's "The Chain", several One Direction songs, as well as previously unreleased material.
Styles made his film debut in Christopher Nolan's war film Dunkirk, in July 2017, playing a British soldier named Alex who is a part of the Dunkirk evacuation in World War II. He appeared alongside an ensemble cast which included Fionn Whitehead, Tom Glynn-Carney, Jack Lowden, Kenneth Branagh, Cillian Murphy, Mark Rylance, and Tom Hardy. Styles beat out "thousands of young men" for the part; Nolan later stated he was unaware of the extent of his fame and that Styles was cast "because he fit the part wonderfully and truly earned a seat at the table." The Daily Telegraph film critic, Robbie Collin, praised Styles for his "bright, convicted, and unexpectedly not-at-all-jarring performance".
In November 2017, BBC One broadcast Harry Styles at the BBC, a one-hour television special presented by Nick Grimshaw. At 2017 ARIA Music Awards, Styles received an award for Best International Artist. He guest hosted The Late Late Show with James Corden in December. Together with Jack Antonoff and Ilsey Juber, Styles co-wrote "Alfie's Song (Not So Typical Love Song)", performed by the band Bleachers, for the soundtrack of the film Love, Simon (2018). He also served as an executive producer on the CBS sitcom Happy Together, which premiered in October 2018 and was inspired by his time living with television producer Ben Winston. In 2018, Styles began modelling for the Italian fashion house Gucci, appearing in several campaigns for the brand.
Styles has received scrutiny for not addressing issues and being lukewarm in political stances. In an April 2017 interview in France, when asked about his view on Brexit, Styles said, “I don’t really comment on politics. I think anything that brings people together is better than things that pull people apart”, adding that equality “doesn’t feel like politics” to him but “feels much more fundamental”. In May 2017, Styles was asked whether issues like Brexit, Black Lives Matter and Donald Trump’s presidency and the sociopolitical unrest has impacted his music. He said that his song “Sign of the Times” is “looking at several different things [...] just the state of the world at the moment”, and “it’s very easy to feel incredibly sad about a lot of things. It’s also nice sometimes to remember that while there’s a lot of bad stuff, there’s also a lot of amazing people doing amazing things in the world.” In an interview with The Times, Styles said he is “probably going to vote for whoever is against Brexit” and that while he is “not educated enough on the subject to really go toe-to-toe with someone about it”, he thinks “what it symbolizes is the opposite of the world I would like to be in. I think the world should be more about being together and being better together and joining together, and I think it’s the opposite of that.”
In November 2017, Styles was criticized for ignoring hundreds of Black Lives Matters signs from fans at his concerts and not showing support for the movement and black fans, and well as making non-committal or “bare minimum” gestures viewed as “damage control”. He later acknowledged race at a concert by saying “If you are black, if you are white [...] I love you all”, receiving mixed responses for “not addressing the problem at hand” and not acknowledging the racial oppression black people face.
"Treat People with Kindness", also abbreviated to "TPWK", is a slogan used by Styles to promote his message of love, acceptance and kindness to people. Styles started using the slogan on his debut concert tour in 2017, on a badge on his guitar and on tour merchandise, including Pride t-shirts sold to raise funds for GLSEN. In an interview in December 2019 he said, "It was a pin I had on my guitar strap and we made t-shirts for it, then I saw a lot of t-shirts around. I'd be driving or something and see someone in one and I started feeling like, 'Oh this is a bit of a thing'". This gave Styles the idea of writing a song to go with the slogan titled "Treat People with Kindness", which is the penultimate track on his second studio album, Fine Line.