0

I am trying to add a border to a widget which is working but it is not capturing the overall the wigets fields only half part is drawing a line

enter image description here

HTML:

    <p class="solid">
   <img src="log.jpg" width="20" height="20"/>

    <div class="input-group">
      <input type="text" ng-model="c.data.message" class="form-control" aria-label="...">
      <div class="input-group-btn">
        <button type="submit" ng-click="c.add()" class="btn btn-primary">Search</button>
      </div>
    </div>

 </p>

CSS:

p.solid {border-style: solid;}
2
  • 1
    You can not nest div into p, that is invalid HTML. The error correction of the browser is fixing your mistake, by closing the p element as soon as it encounters the starting tag of the div. Commented Oct 2, 2019 at 7:05
  • are you closing <p class="solid"> tag? Commented Oct 2, 2019 at 7:06

1 Answer 1

3

A paragraph is not intended as a wrapper for other block elements. The rendering engine will automatically close the <p> tag before opening the <div> that follows, therefore rendering an empty paragraph with no height, resulting in just a border without anything else. Change the paragraph to a <div> (or any other semantically feasible element) and it will work.

.solid {
  border-style: solid;
}
<div class="solid">

  <div class="input-group">
    <input type="text" ng-model="c.data.message" class="form-control" aria-label="...">
    <div class="input-group-btn">
      <button type="submit" ng-click="c.add()" class="btn btn-primary">Search</button>
    </div>
  </div>

</div>

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you Constantin. One quick question why we use .solid in css ? what . refres to ?
. is the class selector. When you add class="solid" you can select it in CSS via .solid, just like you can use id="something" via #something. I'd suggest you find a beginner's tutorial for CSS that explains the very basics. :-)
If your question refers to why it was decided to use that notation - I don't know either. Maybe there's an explanation you can find on the web, otherwise you'd have to ask the inventors of CSS why they decided to use the dot and hash. ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.