Anchor elements are not enclosed by borders

I seem to be overlooking something obvious here, so my apologies in advance. I have the following HTML code and I am trying to use a CSS rule to add a border around the "third-content-wrapper" class. However, the border is only applied to the text and not around the images as I had anticipated. Any ideas on what I might be missing? I could work around this issue by adding a paragraph after the images, but I would prefer to avoid that if possible. Thanks, Alex

<div class="third-content">

 <div class="third-content-wrapper">
    <h2> Interests </h2>
        <p> I enjoy staying active by running, circuit training, and going to the gym. I also love playing tennis, badminton, and table tennis. In addition, I play guitar and have a passion for landscape painting, having studied art at A-Level and GCSE.


  <div id="images-interests">       
    <a href="images/badminton.jpg"> <img src="images/badminton.jpg"> </a>
    <a href="images/guitar.jpg"> <img src="images/guitar.jpg"> </a>
    <a href="images/tennis.jpg"> <img src="images/tennis.jpg"> </a>
    <a href="images/painting1.jpg"> <img src="images/painting1.jpg"> </a>
    </p>
  </div>



 </div>
</div>



.third-content-wrapper{
        border: solid 2px rgba(211,211,211,0.7);
        padding: 10px 30px;

        }

Answer №1

After mentioning using the HTML code below and attempting to apply a CSS rule to place a border around the "third-content-wrapper" class, it seems that the border is only applied to the text and images as expected.

I noticed you were aiming to have the border around the third-content-wrapper, but it appears differently than what you wanted. Maybe something like this could be more aligned with your expectations:

body{
  padding: 0;
  margin: 0;
}

.third-content-wrapper {
  border: solid 2px rgba(211,211,211,0.7);
  padding: 10px 30px;
  width: 100%;
  height: 100vh;
}
<div class="third-content">
 <div class="third-content-wrapper">
    <h2> Interests </h2>
    <p> Enjoying staying active by running, circuit training and attending the gym. Enjoy playing tennis, Badminton & Table tennis. I play guitar and also enjoy landscape painting having done art at A-Level and GCSE.<p>

    <div id="images-interests">       
      <a href="images/badminton.jpg"> <img src="images/badminton.jpg"> </a>
      <a href="images/guitar.jpg"> <img src="images/guitar.jpg"> </a>
      <a href="images/tennis.jpg"> <img src="images/tennis.jpg"> </a>
      <a href="images/painting1.jpg"> <img src="images/painting1.jpg"> </a>
    </div>
 </div>
</div>

The outcome is quite similar, however, when viewed in full screen mode, the alignment may not be exactly as desired. You can adjust the dimensions and consider centering the div within the border for a better result. For instance:

body{
  padding: 0;
  margin: 0;
}

.third-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.third-content-wrapper {
  border: solid 2px rgba(211,211,211,0.7);
  padding: 10px 30px;
  width: 75%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
<div class="third-content">
 <div class="third-content-wrapper">
    <h2> Interests </h2>
    <p> Enjoying staying active by running, circuit training and attending the gym. Enjoy playing tennis, Badminton & Table tennis. I play guitar and also enjoy landscape painting having done art at A-Level and GCSE.<p>

    <div id="images-interests">       
      <a href="images/badminton.jpg"> <img src="images/badminton.jpg"> </a>
      <a href="images/guitar.jpg"> <img src="images/guitar.jpg"> </a>
      <a href="images/tennis.jpg"> <img src="images/tennis.jpg"> </a>
      <a href="images/painting1.jpg"> <img src="images/painting1.jpg"> </a>
    </div>
 </div>
</div>

For additional information on flex-box, you can visit: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Just to note, the approach I took with flex-box can be achieved in a more refined manner :P

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Achieving perfect centering in PrestaShop using CSS for both horizontal

Hello there, I require assistance with aligning some images in the center of my Prestashop webpage. I am specifically struggling with aligning 3 circular images at the bottom of the page (not social icons). I cannot figure out how to properly center these ...

Adjusting the "lang" attribute to modify the font style

By using the HTML lang attribute and setting it to "en", I noticed that some of the div fonts and colors were changing to the default ones in Bootstrap. Although I am utilizing the Bliss2 Regular font, the default font style seems to be taking precedence. ...

Retrieve information from an HTML input field that does not have an assigned ID or name

I am facing a challenge with an HTML table that contains multiple inputs which do not have any id or name attributes. I need to retrieve data from these inputs but struggling due to the lack of identifiers. Upon inspecting the DOM, I noticed that each inp ...

Issue with Google Chrome when entering time using HTML input type time

Hopefully I can figure out a solution for this issue. I am working on an AngularJS project and have the following HTML tag to select time: <input class="input-time" type='time' ng-model="dr.startTime"> The time is displayed in AM/PM forma ...

Incorporate content from a single HTML file into a different one

Hello, I am working with two HTML documents - let's call them index.html and index2.html for this example. I am looking to embed all the code within the body tag of index2.html into a section within index.html. Is there a way to create this connectio ...

I would greatly appreciate your assistance in grasping the CSS code provided

Although I wouldn't consider myself a CSS expert, I usually can figure out how to manipulate code to achieve my desired result. However, the CSS code snippet below has me puzzled and I haven't been able to find any resources to help me make sens ...

What is the best way to adjust the animation settings for SweetAlert2's Toast feature?

I recently integrated SweetAlert2's toast notifications into my web application and customized the animation using the customClass parameter to have the notification slide in from the right side. However, there are a couple of things I'm struggli ...

Adjusting the D3 SVG zoom to focus on a specific rectangle within a group (<g>) at a varying angle

I am working with an <svg> that contains background images and various rectangles positioned correctly within the svg. The rectangles are grouped using <g> tags with translation values and specific rotation angles assigned to each one. My goal ...

tips for passing value to the date field using proctractor

This is the HTML code I am working with: <input id="filter-datepicker" type="daterange" ranges="ranges" class="form-control date-picker" placeholder="Select Date Range" name="sensorDetails.date" ng-model="myDateRange" ranges="ranges" requi ...

Having trouble scaling image with CSS, not reacting to size properties

I have little experience in web development, but a small business client has me working on their website while I handle other tasks for them. I've created a home page design that is almost ready to be turned into a template for the chosen CMS. Things ...

Ways to adjust the color of a navbar link according to the current page you are visiting?

I'm looking to implement a feature on my website where the area around the nav-link darkens when someone navigates to a certain page, making it easier for them to see which page they are currently on. I am working with Bootstrap v4.3.1 and Razor Pages ...

Is there a way to position two bootstrap col divs in alignment with a third col div situated to the left?

I'm attempting to achieve the desired layout shown in this result: https://i.sstatic.net/B3EDr.png Here is the code I have been working with: <div class="container"> <h1>Welcome Dennis,</h1> <div class="col-12 card card- ...

Activate Click, or Pop-up Box

I've been attempting to log in to the Udemy site using JavaScript, but I'm having trouble triggering the click action on the "log in" link. Unfortunately, the .click() method doesn't seem to be working when I try to select the element. The l ...

Customize the dropdown width of the typeahead feature in ng-bootstrap

I recently started using the ng-bootstrap Typeahead component and so far, I am quite satisfied with it. One thing I am trying to figure out is how to make the width of the dropdown items in sync with the input field width. Currently, the default behavior ...

Lack of consideration for height within tables positioned absolutely

In the case of an absolutely positioned element with display: table, if the height is explicitly set and the content exceeds this height, the element will adjust to wrap around the content rather than maintaining the specified height value. #main { wi ...

I'm having trouble getting the gutter padding to show up in one specific content block on my Bootstrap webpage. How can I troubleshoot and resolve this

Currently, I am delving into the realm of Bootstrap 5 and have recently put together a simplistic webpage using the row/column structure suggested by Bootstrap. However, while my other columns seem to be cooperating and displaying the gutter padding as exp ...

Is there a way for me to view the table and information on this website?

Currently, I am in the process of extracting specific data from a table on the following website: . To achieve this, I have opted to use Python along with selenium. The issue arises when attempting to extract the table using read_html() from pandas. Unfor ...

The design of websites does not always translate well to mobile devices

While creating a website that is meant to be responsive across both desktop and mobile screens, I encountered an issue. The design looks perfect on desktop screens, but when viewed on a mobile screen, it shrinks and doesn't fit properly. I am using Bo ...

Adsense ad unit is not responsive and fails to display properly at dimensions of 320x50 px

I have a unique banner ad that I want to display as the footer on my responsive website. Using media queries recommended in the advertising documentation, I am adjusting the size based on different screen widths. Check out the CSS code below: <style&g ...

The reverse animation for .is-exiting in Smoothstate.js is not triggering

I've been searching for a solution to my issue but haven't had any luck finding one that works for me. Currently, I am using smoothstate.js to trigger animations when the page loads and ideally reverse them when the page exits. However, while th ...