News box in html

Adding Recent News Boxes to Your Website

Adding Recent News Boxes to Your Website

Close Icon

One of the most common components to any website is a section that displays a number of your most recent news articles. This helps keep your users engaged and provides the necessary real estate to showcase featured content.

Of course, there are multiple ways to display this type of content, from a vertical list to minimal textual information. An additional way to display recent news is through the use of a box and grid based system. Using this method, you can create the needed space to include a news entry’s featured image, the article’s posting date, and it’s title.

In some designs, it’s important to keep the information displayed to a minimum. Showing a date and an entry’s title is often the only key information needed. Additionally, images tend to drive better click-through-rates and so it’s generally a good idea to showcase a featured image if possible. With this in mind, a simple box container system can accommodate these aspects to a recent news article.

Below is the HTML, CSS, and JavaScript required.

Читайте также:  Css width content width device width initial scale 1

Step 1 — recent-news-boxes.html

Copy and paste the code below into recent-news-boxes.html

Step 2 — recent-news-boxes.css

Download the CSS below and include it in your web page

Step 3 — Add the includes below to your web page

In this tutorial we showed you how to create a section showcasing a number of featured news articles, each contained in it’s own box.

Scott Madara
Contributions Editor here at Solodev. Want to be featured on the Solodev Blog? Get in touch.
Follow me on Twitter

RELATED POSTS

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

An additional way to display recent news is through the use of a box and grid based system. Using this method, you can create the needed space to include a news entry’s featured image, the article’s posting date, and it’s title.

solodev/recent-news-boxes

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

One of the most common components to any website is a section that displays a number of your most recent news articles. This helps keep your users engaged and provides the necessary real estate to showcase featured content.

Of course, there are multiple ways to display this type of content, from a vertical list to minimal textual information. An additional way to display recent news is through the use of a box and grid based system. Using this method, you can create the needed space to include a news entry’s featured image, the article’s posting date, and it’s title.

In this tutorial, Solodev will show you how create a stylized recent news section using boxes..

For detailed instructions, view Solodev’s Adding Recent News Boxes to Your Website article.

Try out a working example on JSFiddle.

The section for these recent news boxes contains the following basic HTML markup.

 

Recent News

News Entry
March1

WebCorpCo Will Be Visiting a Number of Upcoming Conferences

News Entry
February27

WebCorpCo Has Been Named to Inc. 5000

News Entry
February25

7 Crtical Factors when Choosing a CMS

News Entry
February23

The Best Ways to Leverage Data and Deliver on Your Investment

News Entry
February20

Latest API Integrations Available through CMS 8

News Entry
February16

WebCorpCo's Latest Release (CMS 8) Available Today

VIEW ALL NEWS

All required CSS is in recent-news-boxes.css

This tutorial includes the following third party resources.

Источник

How To Add a News and Alerts Section to Your Website

How To Add a News and Alerts Section to Your Website

Close Icon

OK, so it’s probably not a shocker. but we like flashy headlines as much as the next developer.

News is important. That’s why you probably have an entire page on your site dedicated to it, where visitors can see all your activity. But when someone hits your homepage, it’s helpful to feature a bite-sized set of entries. This can be done by creating a shorter, more compact section that features your news and alerts in one place.

It’s not that different from the front page of a newspaper, which gives you the latest-breaking stories with the option to flip to other pages to read more. Remember newspapers?

In this tutorial, we’ll show you how to build a news and alerts section in a neat grid system – perfect for living anywhere on your website. You can list them side by side using Bootstrap columns, so your visitors can peruse the latest headlines while getting updated on critical issues. You can also add images and icons to help your headlines jump off the page and hook your reader in the right manner. We’ve got an example below, but you can get creative with how you display it.

The difference between «news» and «alerts»

Generally speaking, your news can behave a lot like your blog (and in some cases, might even be your blog). The latest articles can be displayed in attractive, well-organized managers that provide a great user experience. The difference is in how you’re engaging with your audience around the nature of your news. Maybe you’re featuring things like press releases or updated product features, but in truth, «news» is whatever your organization feels is «newsworthy.»

Alerts are a little different, as they tend to connote a sense of urgency. With alerts, you might want your audience to take action due to an event or even a crisis – things like road closures or service interruptions. In our COVID-19 series, we showed you how to build a customizable alert bar for your website, so you can keep your customers informed during an emergency like a pandemic (hopefully that’s a rare occurrence).

Alerts are still news, but with a much stronger spotlight. To that end, you can also use tagging or categories to distinguish between the two versus having dedicated pages. That said, for some organizations, subscribing to alert feeds or services might require an independent page or manager, so it’s really driven by your needs.

With your website, you can own your news and alerts without relying solely on other channels. Sure, they provide the distribution – but if you’re feeding your SEO the right way, you can really optimize the performance of your news section and drive greater traffic and awareness. Better still, you can integrate with those outside channels to expand your reach.

Extra, extra – we’ve got the code to bring this life! Keep reading.

Getting Started

Since we’re using Bootstrap to build our section, go ahead and copy and paste the links below in the head section of your project’s HTML file:

HTML

In the HTML code below, we have a main section to house both the news and the alerts. We used the classname .section—news to make it more identifiable and easily select in the CSS file to style it. It is using the Bootstrap grid elements and columns which makes it easier to adjust their width. Both the news and the articles columns are half the width of the section. In smaller screens, the columns take up the full width. We do this by giving each column div a classname of .col-lg-6 .col-12 . In Bootstrap, all divs are divided into 12 columns so col-6 spans 6 of 12 columns making up half the width and col-12 spans 12 of 12 columns making up the full width.

The news and alerts rows are made up of div elements with a classname of .box-news . They’re structurally the same except the news rows have an additional img element to display images. Copy and paste the code below in your project:

CSS

Since most of the layout adjustment and spacing was done via Bootstrap’s built-in classes used in the HTML file, we set properties such as colors, font sizes, and link styling via CSS. Feel free to change the color and the styling of the fonts to match your website’s branding:

And there it is! Check out the JSFiddle below to see the demo before committing to its use:

Источник

Оцените статью